text
stringlengths
1
1.05M
; A127365: Signed repeated natural numbers. ; 0,0,-1,-1,2,2,-3,-3,4,4,-5,-5,6,6,-7,-7,8,8,-9,-9,10,10,-11,-11,12,12,-13,-13,14,14,-15,-15,16,16,-17,-17,18,18,-19,-19,20,20,-21,-21,22,22,-23,-23,24,24,-25,-25,26,26,-27,-27,28,28,-29,-29,30,30,-31,-31,32,32,-33,-33,34,34,-35,-35,36,36,-37,-37,38,38,-39,-39,40,40,-41,-41,42,42,-43,-43,44,44,-45,-45,46,46,-47,-47,48,48,-49,-49 div $0,2 mov $1,-1 pow $1,$0 mul $1,$0 mov $0,$1
/* g++ --std=c++20 -pthread -o ../_build/cpp/memory_ranges_uninitialized_fill_1.exe ./cpp/memory_ranges_uninitialized_fill_1.cpp && (cd ../_build/cpp/;./memory_ranges_uninitialized_fill_1.exe) https://en.cppreference.com/w/cpp/memory/ranges/uninitialized_fill */ #include <iostream> #include <memory> #include <string> int main() { constexpr int n {4}; alignas(alignof(std::string)) char out[n * sizeof(std::string)]; try { auto first {reinterpret_cast<std::string*>(out)}; auto last {first + n}; std::ranges::uninitialized_fill(first, last, "▄▀▄▀▄▀▄▀"); int count {1}; for (auto it {first}; it != last; ++it) { std::cout << count++ << ' ' << *it << '\n'; } std::ranges::destroy(first, last); } catch(...) { std::cout << "Exception!\n"; } }
<% from pwnlib.shellcraft.aarch64.linux import syscall %> <%page args="scp"/> <%docstring> Invokes the syscall sigreturn. See 'man 2 sigreturn' for more information. </%docstring> ${syscall('SYS_sigreturn')}
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) Geoworks 1994 -- All Rights Reserved PROJECT: PC GEOS MODULE: CommonUI/CMain FILE: cmainPenInputControl.asm AUTHOR: David Litwin, Apr 8, 1994 ROUTINES: Name Description ---- ----------- GLB OLPenInputControl Open look pen input control class REVISION HISTORY: Name Date Description ---- ---- ----------- dlitwin 4/ 8/94 Initial revision this entire file was moved from the UI to the SPUI. The old file was: /staff/pcgeos/Library/User/UI/uiPenInput.asm DESCRIPTION: Code for the OLPenInputControlClass $Id: cmainPenInputControl.asm,v 1.1 97/04/07 10:52:08 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CommonUIClassStructures segment resource OLPenInputControlClass mask CLASSF_NEVER_SAVED or \ mask CLASSF_DISCARD_ON_SAVE if not _GRAFFITI_UI VisCachedGStateClass NotifyEnabledStateGenViewClass endif CommonUIClassStructures ends ;--------------------------------------------------- ControlCommon segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GenPenInputControlInitialize %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Initializes the travel option of the object, and adds hints to keep object on screen. CALLED BY: GLOBAL PASS: nothing RETURN: nothing DESTROYED: ax, cx, dx, bp PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 11/30/92 Initial version dlitwin 4/18/94 Added call to superclass because we are built into a specific class now. dlitwin 4/27/94 Added in the code that used to be the handler of the ResolveVariantSuperclass, because that has a different purpose now that we are in the SPUI. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLPenInputControlInitialize method dynamic OLPenInputControlClass, MSG_META_INITIALIZE ; ; Make the window stay above all other windows ; mov ax, ATTR_GEN_WINDOW_CUSTOM_WINDOW_PRIORITY mov cx, size WinPriority call ObjVarAddData mov {WinPriority} ds:[bx], WIN_PRIO_POPUP+1 if _GRAFFITI_UI and 0 ;Graffiti shouldn't appear above sys modals - brianc 6/12/95 ; ; Give the thing a custom layer priority so it shows up ; in front of the password dialog box. Also makes it show ; up in front of error dialogs, including sysmodal ones. ; So it goes. ; mov ax, ATTR_GEN_WINDOW_CUSTOM_LAYER_PRIORITY mov cx, size LayerPriority call ObjVarAddData mov {WinPriority} ds:[bx], LAYER_PRIO_MODAL-1 endif ; ; Give the window a custom parent window (the system screen window) ; so it'll stay above system modal dialogs. - Joon (7/8/94) ; mov ax, ATTR_GEN_WINDOW_CUSTOM_PARENT mov cx, size hptr call ObjVarAddData mov {hptr.Window} ds:[bx], NULL ; system screen window ; ; Add various hints/attributes. ; mov ax, ATTR_GEN_WINDOW_ACCEPT_INK_EVEN_IF_NOT_FOCUSED clr cx ; hint has no extra data call ObjVarAddData mov ax, HINT_TOOLBOX call ObjVarAddData ; also has no extra data mov ax, HINT_MINIMIZE_CHILD_SPACING call ObjVarAddData ; also has no extra data mov ax, HINT_CENTER_CHILDREN_HORIZONTALLY call ObjVarAddData ; also has no extra data mov ax, HINT_DISMISS_WHEN_DISABLED call ObjVarAddData ; also has no extra data if not _GRAFFITI_UI if STYLUS_KEYBOARD mov ax, HINT_KEEP_ENTIRELY_ONSCREEN call ObjVarAddData ; also has no extra data mov ax, HINT_WINDOW_MINIMIZE_TITLE_BAR call ObjVarAddData ; also has no extra data mov ax, HINT_WINDOW_ALWAYS_DRAW_WITH_FOCUS call ObjVarAddData ; also has no extra data mov ax, HINT_INITIAL_SIZE mov cx, (size SpecWidth) + (size SpecHeight) call ObjVarAddData mov {word} ds:[bx], (SST_PIXELS shl offset SW_TYPE) or \ STYLUS_BK_KEYBOARD_WIDTH mov {word} ds:[bx+2], (SST_PIXELS shl offset SW_TYPE) or \ STYLUS_BK_KEYBOARD_HEIGHT else ; ; Put this hint on the box, to keep the box from being ; forced onscreen every time it is brought up. ; mov ax, HINT_DONT_KEEP_INITIALLY_ONSCREEN or mask VDF_SAVE_TO_STATE call ObjVarAddData ; also has no extra data endif endif ; ; Let our superclass do its thing ; mov ax, MSG_META_INITIALIZE mov di, offset OLPenInputControlClass call ObjCallSuperNoLock ; ; Set our block's output to the app focus so our keypresses go ; to the right place. ; mov di, ds:[si] add di, ds:[di].Gen_offset movdw ds:[di].GCI_output, TO_APP_FOCUS ; ; If we are a developer defined PIC ('embedded') we will want to ; skip putting ourselves on the active list. Because embedded ; keyboards aren't supported right now, we don't want the user ; provided one to put itself on the list and then not take itself ; off. ; mov ax, ATTR_GEN_PEN_INPUT_CONTROL_IS_FLOATING_KEYBOARD call ObjVarFindData jnc setNotUsable ; ; Add the object to the active list, then send ; MSG_GEN_CONTROL_ADD_TO_GCN_LISTS so it'll add itself ; to the appropriate GCNLists when it is restored from ; state. If we aren't on these lists a bunch of messages ; won't get handled, and the keyboard won't come up. ; ; We do this here so that anyone using an embedded keyboard ; won't have to worry about making sure it is on this list, ; the object does it itself. ; mov ax, MSG_META_GCN_LIST_ADD mov dx, size GCNListParams sub sp, dx mov bp, sp mov cx, ds:[LMBH_handle] movdw ss:[bp].GCNLP_optr, cxsi mov ss:[bp].GCNLP_ID.GCNLT_manuf, MANUFACTURER_ID_GEOWORKS mov ss:[bp].GCNLP_ID.GCNLT_type, MGCNLT_ACTIVE_LIST or mask GCNLTF_SAVE_TO_STATE call UserCallApplication add sp, size GCNListParams mov ax, MSG_GEN_CONTROL_ADD_TO_GCN_LISTS call ObjCallInstanceNoLock exit: ret setNotUsable: ; ; The only way to get here is if ; ATTR_GEN_PEN_INPUT_CONTROL_IS_FLOATING_KEYBOARD is NOT set, ; meaning that this is a user defined keyboard. ; ; ; If we are a developer defined PIC ('embedded') we will want to ; set ourselves not usable. Because embedded keyboards aren't ; supported right now, we don't want the user provided one to pop ; up and conflict with the app generated one. ; mov ax, MSG_GEN_SET_NOT_USABLE mov dl, VUM_NOW call ObjCallInstanceNoLock jmp exit OLPenInputControlInitialize endp COMMENT @---------------------------------------------------------------------- MESSAGE: OLPenInputControlGetInfo -- MSG_GEN_CONTROL_GET_INFO for OLPenInputControlClass DESCRIPTION: Return group PASS: *ds:si - instance data es - segment of OLPenInputControlClass ax - The message cx:dx - GenControlBuildInfo structure to fill in RETURN: none DESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 10/31/91 Initial version ------------------------------------------------------------------------------@ OLPenInputControlGetInfo method dynamic OLPenInputControlClass, MSG_GEN_CONTROL_GET_INFO .enter mov es, cx mov di, dx ;es:di = dest segmov ds, cs mov si, offset GPIC_dupInfo CheckHack <(GenControlBuildInfo and 1) eq 0> mov cx, size GenControlBuildInfo / 2 rep movsw .leave ret OLPenInputControlGetInfo endm if PEN_INPUT_CONTROL_ALWAYS_ACTIVE ;add CUSTOM_ENABLE_DISABLE, ALWAYS_INTERACTABLE, and ALWAYS_UPDATE GPIC_dupInfo GenControlBuildInfo < mask GCBF_CUSTOM_ENABLE_DISABLE or \ mask GCBF_ALWAYS_INTERACTABLE or \ mask GCBF_ALWAYS_UPDATE or \ mask GCBF_NOT_REQUIRED_TO_BE_ON_SELF_LOAD_OPTIONS_LIST or \ mask GCBF_DO_NOT_DESTROY_CHILDREN_WHEN_CLOSED or \ mask GCBF_SPECIFIC_UI or \ mask GCBF_ALWAYS_ON_GCN_LIST or \ mask GCBF_IS_ON_ACTIVE_LIST or \ mask GCBF_MANUALLY_REMOVE_FROM_ACTIVE_LIST, ; GCBI_flags GPIC_IniFileKey, ; GCBI_initFileKey GPIC_gcnList, ; GCBI_gcnList length GPIC_gcnList, ; GCBI_gcnCount GPIC_notifyTypeList, ; GCBI_notificationList length GPIC_notifyTypeList, ; GCBI_notificationCount GPICName, ; GCBI_controllerName handle GenPenInputControlUI, ; GCBI_dupBlock GPIC_childList, ; GCBI_childList length GPIC_childList, ; GCBI_childCount GPIC_featuresList, ; GCBI_featuresList length GPIC_featuresList, ; GCBI_featuresCount GPIC_DEFAULT_FEATURES, ; GCBI_features handle GenPenInputControlToolboxUI, ; GCBI_toolBlock GPIC_toolList, ; GCBI_toolList length GPIC_toolList, ; GCBI_toolCount GPIC_toolFeaturesList, ; GCBI_toolFeaturesList length GPIC_toolFeaturesList, ; GCBI_toolFeaturesCount GPIC_DEFAULT_TOOLBOX_FEATURES> ; GCBI_toolFeatures else GPIC_dupInfo GenControlBuildInfo < mask GCBF_NOT_REQUIRED_TO_BE_ON_SELF_LOAD_OPTIONS_LIST or \ mask GCBF_DO_NOT_DESTROY_CHILDREN_WHEN_CLOSED or \ mask GCBF_SPECIFIC_UI or \ mask GCBF_ALWAYS_ON_GCN_LIST or \ mask GCBF_IS_ON_ACTIVE_LIST or \ mask GCBF_MANUALLY_REMOVE_FROM_ACTIVE_LIST, ; GCBI_flags GPIC_IniFileKey, ; GCBI_initFileKey GPIC_gcnList, ; GCBI_gcnList length GPIC_gcnList, ; GCBI_gcnCount GPIC_notifyTypeList, ; GCBI_notificationList length GPIC_notifyTypeList, ; GCBI_notificationCount GPICName, ; GCBI_controllerName handle GenPenInputControlUI, ; GCBI_dupBlock GPIC_childList, ; GCBI_childList length GPIC_childList, ; GCBI_childCount GPIC_featuresList, ; GCBI_featuresList length GPIC_featuresList, ; GCBI_featuresCount GPIC_DEFAULT_FEATURES, ; GCBI_features handle GenPenInputControlToolboxUI, ; GCBI_toolBlock GPIC_toolList, ; GCBI_toolList length GPIC_toolList, ; GCBI_toolCount GPIC_toolFeaturesList, ; GCBI_toolFeaturesList length GPIC_toolFeaturesList, ; GCBI_toolFeaturesCount GPIC_DEFAULT_TOOLBOX_FEATURES> ; GCBI_toolFeatures endif if _FXIP ControlInfoXIP segment resource endif GPIC_IniFileKey char "penInputControl", 0 GPIC_gcnList GCNListType \ <MANUFACTURER_ID_GEOWORKS, GAGCNLT_NOTIFY_FOCUS_TEXT_OBJECT>, <MANUFACTURER_ID_GEOWORKS, GAGCNLT_CONTROLLERS_WITHIN_USER_DO_DIALOGS>, <MANUFACTURER_ID_GEOWORKS, GAGCNLT_FOCUS_WINDOW_KBD_STATUS> GPIC_notifyTypeList NotificationType \ <MANUFACTURER_ID_GEOWORKS, GWNT_EDITABLE_TEXT_OBJECT_HAS_FOCUS> ;--- GPIC_childList GenControlChildInfo \ <offset PenGroup, \ mask GPICF_KEYBOARD or \ mask GPICF_CHAR_TABLE or \ mask GPICF_CHAR_TABLE_SYMBOLS or \ mask GPICF_CHAR_TABLE_INTERNATIONAL or \ mask GPICF_HWR_ENTRY_AREA or \ mask GPICF_CHAR_TABLE_CUSTOM \ , 0> ; Careful, this table is in the *opposite* order as the record which ; it corresponds to. if _GRAFFITI_UI ;no features for _GRAFFITI_UI GPIC_featuresList GenControlFeaturesInfo <> else GPIC_featuresList GenControlFeaturesInfo \ <offset TitleHWRGridItem, HWRGridName>, <offset TitleCharTableCustomItem, CharTableCustomName>, <offset TitleCharTableMathItem, CharTableMathName>, <offset TitleCharTableSymbolsItem, CharTableSymbolsName>, <offset TitleCharTableInternationalItem, CharTableInternationalName>, <offset TitleCharTableItem, CharTableName>, <offset TitleKeyboardItem, KeyboardName> endif ;--- if _GRAFFITI_UI ;no tools for _GRAFFITI_UI GPIC_toolList GenControlChildInfo <> else GPIC_toolList GenControlChildInfo \ <offset InitiateTrigger, mask GPICTF_INITIATE, mask GCCF_IS_DIRECTLY_A_FEATURE> endif ; Careful, this table is in the *opposite* order as the record which ; it corresponds to. if _GRAFFITI_UI ;no tool features for _GRAFFITI_UI GPIC_toolFeaturesList GenControlFeaturesInfo <> else GPIC_toolFeaturesList GenControlFeaturesInfo \ <offset InitiateTrigger, InitiatePenInputName> endif if _FXIP ControlInfoXIP ends endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLPenInputControlSetToDefaultPosition %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the PIC to its default position. CALLED BY: MSG_GEN_PEN_INPUT_CONTROL_SET_TO_DEFAULT_POSITION PASS: *ds:si = OLPenInputControlClass object cx = width of field RETURN: nothing DESTROYED: cx SIDE EFFECTS: Potentially (if non-stylus) leaves a MSG_GEN_SET_WIN_CONSTRAIN (with WCT_KEEP_PARTIALLY_VISIBLE) on the front of the queue, so if you are going to bring up the PIC, make sure you send your MSG_GEN_INTERACTION_INITIATE with MF_FORCE_QUEUE and MF_INSERT_AT_FRONT *after* this message is handled, so it will then insert itself on the queue before the win constrain can take effect. Things need to be done this way because of how the UI Application code brings up the keyboard, so you are really better off sending a MSG_GEN_PEN_INPUT_CONTROL_BRING_UP_EMBEDDED_KEYBOARD. PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- dlitwin 6/ 2/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if not _GRAFFITI_UI ;not needed for _GRAFFITI_UI OLPenInputControlSetToDefaultPosition method dynamic OLPenInputControlClass, MSG_GEN_PEN_INPUT_CONTROL_SET_TO_DEFAULT_POSITION uses ax, dx, bp .enter mov bx, ds:[LMBH_handle] if not STYLUS_KEYBOARD ; ; If the position is -1, use the system default position ; (centered horizontally at bottom of screen). We do this ; by constraining the window to stay on screen, moving it ; off the bottom edge of the screen, then unconstraining ; the window. ; mov dl, VUM_MANUAL mov dh, WCT_KEEP_VISIBLE mov ax, MSG_GEN_SET_WIN_CONSTRAIN mov di, mask MF_FIXUP_DS push cx call ObjMessage pop cx endif ; if (not STYLUS_KEYBOARD) ; ; Get the estimated width of keyboard for centering purposes ; IKBD < push es > IKBD < segmov es, dgroup, ax ;es = dgroup > IKBD < cmp es:[floatingKbdSize], KS_STANDARD > IKBD < pop es > IKBD < mov ax, STANDARD_GUESSTIMATE_OF_FLOATING_KBD_WIDTH > IKBD < je standard > IKBD < mov ax, ZOOMER_GUESSTIMATE_OF_FLOATING_KBD_WIDTH > IKBD <standard: > NOTIKBD<mov ax, KEYBOARD_GUESSTIMATE_OF_FLOATING_KBD_WIDTH > sub cx, ax jns positive clr cx positive: shr cx, 1 mov dh, WPT_AT_SPECIFIC_POSITION mov bp, 4000 ;Off the bottom of the screen mov dl, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_WIN_POSITION mov di, mask MF_FIXUP_DS call ObjMessage if not STYLUS_KEYBOARD ; ; We want the window to be constrained to the screen while ; it comes up, then we want to nuke the constrain, so we ; insert this message at the front of the queue, where it ; will arrive after the box is brought up. See BringUpKeyboard. ; We don't bother if we aren't enabled though, as we want ; the constrain to be WCT_KEEP_VISIBLE when we initiate the ; thing, and if we are disabled we aren't going to initiate ; at this point. When we do (later when being set enabled) ; we will reset the winconstrain back. ; mov ax, MSG_GEN_GET_ENABLED call ObjCallInstanceNoLock jnc afterConstrainReset mov ax, MSG_GEN_SET_WIN_CONSTRAIN mov dx, (WCT_KEEP_PARTIALLY_VISIBLE shl 8) or VUM_MANUAL mov di, mask MF_FORCE_QUEUE or mask MF_INSERT_AT_FRONT call ObjMessage afterConstrainReset: endif ; if (not STYLUS_KEYBOARD) .leave ret OLPenInputControlSetToDefaultPosition endm endif ; if (not _GRAFFITI_UI) ControlCommon ends GenPenInputControlCode segment resource if not _GRAFFITI_UI ;not needed for _GRAFFITI_UI ObjMessageFixupDS proc near mov di, mask MF_FIXUP_DS call ObjMessage ret ObjMessageFixupDS endp ObjMessageCall proc near mov di, mask MF_FIXUP_DS or mask MF_CALL call ObjMessage ret ObjMessageCall endp if not STYLUS_KEYBOARD COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetupCustomCharTable %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Sets up the data/moniker for the custom character table. CALLED BY: GLOBAL PASS: *ds:si - GenPenInputControl object bx - child block RETURN: nada DESTROYED: cx, dx, bp PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 10/23/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetupCustomCharTable proc near uses ax .enter ; Setup the chartable information, if the custom char table exists. push bx mov ax, ATTR_GEN_PEN_INPUT_CONTROL_CUSTOM_CHAR_TABLE_DATA call ObjVarFindData ;ds:bx - ptr to extra data EC < ERROR_NC NO_CUSTOM_CHAR_TABLE_DATA > movdw dxbp, dsbx pop bx ;Add custom characters to the CharTableData structure push si mov ax, MSG_CHAR_TABLE_GET_CUSTOM_CHAR_TABLE_DATA mov si, offset CharTableCustomObj ;^lBX:SI <- CharTableCustomObj call ObjMessageFixupDS pop si .leave ret SetupCustomCharTable endp endif ; if (not STYLUS_KEYBOARD) COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DetermineStartupMode %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Determines which PenInputDisplayType should be active. CALLED BY: GLOBAL PASS: *ds:si - GenPenInputControl object bx - child block RETURN: cx - PenInputDisplayType DESTROYED: nada PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 11/17/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ keyName char "penInputDisplayType",0 category char "ui",0 DetermineStartupMode proc near uses ax, bx, dx, bp, di, si .enter ; Check if the object has an attribute stating which item ; to select. push bx mov ax, ATTR_GEN_PEN_INPUT_CONTROL_STARTUP_DISPLAY_TYPE call ObjVarFindData mov cx, ds:[bx] pop bx jc common ; Look in the .ini file for a default display to bring up. push dx, ds, si segmov ds, cs, cx mov dx, offset keyName mov si, offset category call InitFileReadInteger mov_tr cx, ax pop dx, ds, si jc findFirst common: EC < cmp cx, PenInputDisplayType > EC < ERROR_AE BAD_PEN_INPUT_DISPLAY_TYPE > ; Make sure that the desired identifier exists push cx mov ax, MSG_GEN_ITEM_GROUP_GET_ITEM_OPTR call CallDisplayList pop cx jc exit ;Exit if item with identifier exists ; ; Either the desired identifier did not exist, or there was no ; preference provided by the app, so just select the first one in ; the list. ; For Stylus just default to BigKeys, as we are in a situation ; where our choices are fairly hardcoded. Regular keyboard and ; HWR Grid can be turned on and off with feature bits, but the ; stylus specific stuff doesn't have feature bits. dlitwin 9/5/94 ; findFirst: if STYLUS_KEYBOARD mov cx, PIDT_BIG_KEYS else mov ax, MSG_GEN_ITEM_GROUP_SCAN_ITEMS mov cl, mask GSIF_FROM_START or mask GSIF_FORWARD clr bp call CallDisplayList ;Return AX = identifier to ; give the selection to mov_tr cx, ax ;CX <- identifier of item to ; select. endif exit: .leave ret DetermineStartupMode endp if not STYLUS_KEYBOARD COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetObjectUsable %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Sets the passed object usable CALLED BY: GLOBAL PASS: ^lBX:DX <- object DS - obj block RETURN: nada DESTROYED: cx, dx, bp, di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 2/11/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetObjectUsable proc near uses ax, si .enter mov ax, MSG_GEN_SET_USABLE mov si, dx mov dl, VUM_NOW call ObjMessageFixupDS .leave ret SetObjectUsable endp endif ; if (not STYLUS_KEYBOARD) endif ; if (not _GRAFFITI_UI) COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLPenInputControlGetMainView %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Return the PenInputView. For now there will always be a main view (for all of the Motif and Stylus keyboards), but who knows in the future, so support for having no main view is in the API (carry set, null optr). CALLED BY: MSG_GEN_PEN_INPUT_CONTROL_GET_MAIN_VIEW PASS: *ds:si = OLPenInputControlClass object RETURN: carry = set if there is no main view ^lcx:dx = null = clear if one exists: ^lcx:dx = optr of main view DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- dlitwin 5/31/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLPenInputControlGetMainView method dynamic OLPenInputControlClass, MSG_GEN_PEN_INPUT_CONTROL_GET_MAIN_VIEW if _GRAFFITI_UI ;return nothing for _GRAFFITI_UI clr cx, dx stc else uses ax .enter call PI_GetFeaturesAndChildBlock mov cx, bx clr dx stc jcxz exit mov dx, offset PenInputView clc exit: .leave endif ret OLPenInputControlGetMainView endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLPenInputControlGenerateUI %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: We mess with the UI after it has been generated. CALLED BY: GLOBAL PASS: *ds:si - GenPenInputControl object RETURN: nada DESTROYED: nada PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 4/27/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLPenInputControlGenerateUI method OLPenInputControlClass, MSG_GEN_CONTROL_GENERATE_UI .enter ;JEDI if _GRAFFITI_UI push ds mov bx, handle ControlStrings ;^hbx = string block call MemLock ;ax = string seg ptr mov ds, ax ;ds = string seg ptr mov_tr cx, ax ;cx = string seg ptr mov bx, offset GraffitiName ;*ds:bx = str mov bx, ds:[bx] ;ds:bx = str mov dx, bx ;cx:dx = str pop ds ;restore ds mov ax, MSG_GEN_REPLACE_VIS_MONIKER_TEXT mov bp, VUM_NOW call ObjCallInstanceNoLock mov bx, handle ControlStrings call MemUnlock endif if not _GRAFFITI_UI call PI_GetFeaturesAndChildBlock tst ax jz exit call DetermineStartupMode ;CX <- identifier of item to ; give the selection to. EC < cmp cx, PenInputDisplayType > EC < ERROR_AE CONTROLLER_OBJECT_INTERNAL_ERROR > mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION clr dx call CallDisplayList call ForceApplyMsg exit: endif .leave ret OLPenInputControlGenerateUI endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ForceApplyMsg %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Forces the display list to send out its apply message CALLED BY: GLOBAL PASS: bx <- child block RETURN: nada DESTROYED: ax, cx, dx, bp PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 4/27/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if not _GRAFFITI_UI ;not needed for _GRAFFITI_UI ForceApplyMsg proc near mov ax, MSG_GEN_ITEM_GROUP_SET_MODIFIED_STATE mov cx, TRUE call CallDisplayList mov ax, MSG_GEN_APPLY GOTO CallDisplayList ForceApplyMsg endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLPenInputControlTweakDuplicatedUI %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: When we become interactable, check the status of the list and add the appropriate object. CALLED BY: GLOBAL PASS: *ds:si = OLPenInputControlClass object es = segment of OLPenInputControlClass (ui's dgroup) cx = child block dx = features mask RETURN: nada DESTROYED: nada PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 7/10/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLPenInputControlTweakDuplicatedUI method OLPenInputControlClass, MSG_GEN_CONTROL_TWEAK_DUPLICATED_UI .enter if _GRAFFITI_UI ; ; tell graffiti dialog to initialize itself ; Routine below destroys ax, bx, di ; push cx, dx, si if PEN_INPUT_CONTROL_ALWAYS_ACTIVE ; ; add GraffitiGroup (KeyboardControl) to active list ; push cx, si clr bx call GeodeGetAppObject ; ^lbx:si = app obj mov dx, size GCNListParams sub sp, dx mov bp, sp mov ss:[bp].GCNLP_ID.GCNLT_manuf, MANUFACTURER_ID_GEOWORKS mov ss:[bp].GCNLP_ID.GCNLT_type, MGCNLT_ACTIVE_LIST mov ss:[bp].GCNLP_optr.handle, cx mov ss:[bp].GCNLP_optr.offset, offset GraffitiGroup mov ax, MSG_META_GCN_LIST_ADD mov di, mask MF_CALL or mask MF_STACK or mask MF_FIXUP_DS call ObjMessage add sp, size GCNListParams pop cx, si endif ; if PEN_INPUT_CONTROL_ALWAYS_ACTIVE mov bx, cx mov si, offset GraffitiGroup mov ax, MSG_META_INITIALIZE mov di, mask MF_CALL or mask MF_FIXUP_DS call ObjMessage pop cx, dx, si endif ; if _GRAFFITI_UI if not _GRAFFITI_UI ;not needed for _GRAFFITI_UI ; ; Stylus doesn't do any of this crap, it just checks to see if ; the HWRGrid or VisKeyboard's feature bits are set and dynamically ; substitutes their keys to switch to them with greyed out versions. ; if STYLUS_KEYBOARD call StylusCheckForDisabledHWRGridOrVisKeyboard else segmov es, dgroup, ax mov bx, cx mov ax, dx tst ax ;Exit if no features LONG jz exit IKBD < call InitPenInputControlUISizes > ; ; If there is more than one feature enabled, set the tool bar usable. ; push ax clr dx mov cx, offset GPICF_KEYBOARD + 1 ;CX <- # features nextBit: shr ax adc dx, 0 loop nextBit ;DX <- # bits set pop ax cmp dx, 2 ;If only one entry mode available, jb noToolBar ; don't show any of the rest of the ; junk. ; ; Set the size of the HWR Grid object (it is smaller in dialog box ; controllers). ; test ax, mask GPICF_HWR_ENTRY_AREA jz noHWREntryArea push ax, si mov ax, MSG_VIS_SET_SIZE mov si, offset HWRGridObj IKBD_EC<call ECCheckESDGroup > IKBD < push es > IKBD < segmov es, dgroup, cx > IKBD < mov cx, es:[charTableWidth] > IKBD < mov dx, es:[hwrGridHeight] > IKBD < add dx, es:[hwrGridVerticalMargin] > IKBD < add dx, 2 > IKBD < pop es > NOTIKBD<mov cx, FLOATING_KEYBOARD_MAX_WIDTH > NOTIKBD<mov dx, KEYBOARD_HWR_GRID_HEIGHT + KEYBOARD_HWR_GRID_VERTICAL_MARGIN + 2 > call ObjMessageFixupDS pop ax, si noHWREntryArea: ; Add the TitlePenToolGroup to the controller, and set it usable (it must ; be a direct child of the controller, or else it won't appear in the ; correct place). ; push ax mov ax, MSG_GEN_ADD_CHILD mov cx, bx mov dx, offset TitlePenToolGroup mov bp, CCO_LAST call ObjCallInstanceNoLock pop ax setUsable: call SetObjectUsable noToolBar: test ax, mask GPICF_CHAR_TABLE_CUSTOM jz noCharTable call SetupCustomCharTable noCharTable: test ax, mask GPICF_HWR_ENTRY_AREA jz noHWRGrid push si mov ax, MSG_VIS_TEXT_CREATE_STORAGE mov cx, mask VTSF_MULTIPLE_CHAR_ATTRS mov si, offset HWRContextObj call ObjMessageFixupDS pop si ; ; Set the doc bounds of the view - we do this explicitly because we ; may be figuring out the geometry now. ; noHWRGrid: call DetermineStartupMode ;CX <- identifier of item to ; give the selection to. EC < cmp cx, PenInputDisplayType > EC < ERROR_AE CONTROLLER_OBJECT_INTERNAL_ERROR > IKBD_EC<call ECCheckESDGroup > IKBD < mov dx, es:[charTableHeight] > IKBD < inc dx > NOTIKBD<mov dx, FLOATING_KEYBOARD_MAX_HEIGHT > cmp cx, PIDT_HWR_ENTRY_AREA jne setBounds IKBD < mov dx, es:[hwrGridHeight] > IKBD < add dx, es:[hwrGridVerticalMargin] > IKBD < add dx, 3 > NOTIKBD<mov dx, KEYBOARD_HWR_GRID_HEIGHT+KEYBOARD_HWR_GRID_VERTICAL_MARGIN+3 > setBounds: IKBD_EC<call ECCheckESDGroup > IKBD < mov cx, es:[charTableWidth] > NOTIKBD<mov cx, FLOATING_KEYBOARD_MAX_WIDTH > mov si, offset PenInputView clr di ; no fixup DS or ES call GenViewSetSimpleBounds exit: endif ; endif if of else of if STYLUS_KEYBOARD endif ; if (not _GRAFFITI_UI) .leave ret OLPenInputControlTweakDuplicatedUI endp if STYLUS_KEYBOARD COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% StylusCheckForDisabledHWRGridOrVisKeyboard %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Stylus doesn't do any of this crap, it just checks to see if the HWRGrid or VisKeyboard's feature bits are set and dynamically substitutes their keys to switch to them with greyed out versions. CALLED BY: OLPenInputControlTweakDuplicatedUI PASS: cx = childblock dx = features mask RETURN: nothing DESTROYED: bx, di, si SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- dlitwin 9/ 2/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ StylusCheckForDisabledHWRGridOrVisKeyboard proc near uses ax, cx, dx, bp .enter mov bx, cx ; put childblock in bx test dx, mask GPICF_HWR_ENTRY_AREA jnz skipHWRStuff push dx mov ax, MSG_VIS_KEYMAP_ADD_SUBSTITUTE_CHAR SBCS < mov dx, (CS_CONTROL shl 8) or C_CTRL_G ; normal HWRGrid > ; special char DBCS < mov dx, C_SYS_CTRL_G > SBCS < mov bp, (CS_CONTROL shl 8) or C_CTRL_V ; greyed HWRGrid > ; special char DBCS < mov bp, C_SYS_CTRL_V > mov di, mask MF_CALL or mask MF_FIXUP_DS call StylusSendToKeymaps mov ax, MSG_META_ADD_VAR_DATA mov dx, size AddVarDataParams sub sp, dx mov bp, sp mov ss:[bp].AVDP_dataType, ATTR_VIS_KEYBOARD_NO_HWR_GRID clr ss:[bp].AVDP_dataSize mov si, offset KeyboardObj mov di, mask MF_CALL or mask MF_FIXUP_DS call ObjMessage add sp, size AddVarDataParams pop dx skipHWRStuff: test dx, mask GPICF_KEYBOARD jnz exit mov ax, MSG_VIS_KEYMAP_ADD_SUBSTITUTE_CHAR SBCS < mov dx, (CS_CONTROL shl 8) or C_CTRL_D ; normal Keyboard > ; spec. char DBCS < mov dx, C_SYS_CTRL_D > SBCS < mov bp, (CS_CONTROL shl 8) or C_CTRL_U ; greyed Keyboard > ; spec. char DBCS < mov bp, C_SYS_CTRL_U > mov di, mask MF_CALL or mask MF_FIXUP_DS call StylusSendToKeymaps exit: .leave ret StylusCheckForDisabledHWRGridOrVisKeyboard endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% StylusSendToKeymaps %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Send a message to all the various VisKeymapClass objects CALLED BY: StylusCheckForDisabledHWRGridOrVisKeyboard PASS: ax = Message bx = childblock dx,bp= data to pass di = MessageFlags RETURN: nothing DESTROYED: ax, cx, dx, bp, si SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- dlitwin 9/ 2/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ StylusSendToKeymaps proc near .enter mov si, offset VisKeymapObjectsTable loopTop: tst <{word} cs:[si]> jz exit push ax, cx, dx, bp, si, di mov si, cs:[si] ; get lptr of VisKeymapClass obj call ObjMessage pop ax, cx, dx, bp, si, di inc si inc si ; next lptr jmp loopTop exit: .leave ret StylusSendToKeymaps endp VisKeymapObjectsTable lptr \ offset BigKeysObj, offset NumbersObj, offset PunctuationObj, offset HWRGridPICGadgetsKeymap, 0 endif ; if STYLUS_KEYBOARD if INITFILE_KEYBOARD COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% InitPenInputControlUISizes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: If we are checking our initfile for the type of keyboard we want (standard (bullet) or Zoomer), we may have to change the constants that are set up in the block of UI we duplicated. It defaults to standard, so if our .ini file says standard we don't have to do anything. If the .ini file says Zoomer, we update these objects to have Zoomer constants. CALLED BY: OLPenInputControlTweakDuplicatedUI PASS: es = dgroup ^hbx = block of UI to tweak RETURN: nothing DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- dlitwin 5/ 3/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ InitPenInputControlUISizes proc near uses ax,bx,cx,dx,si,di,bp .enter EC < call ECCheckESDGroup > cmp es:[floatingKbdSize], KS_STANDARD LONG je exit EC< cmp es:[floatingKbdSize], KS_ZOOMER > EC< ERROR_NE ERROR_PEN_INPUT_CONTROL_BAD_KEYBOARD_SIZE > ; ; Set the fixed sizes of the PenGroup and HWRContextGroup ; to the Zoomer constants. ; mov dx, size SetSizeArgs sub sp, dx mov bp, sp clr ss:[bp].SSA_width mov ss:[bp].SSA_height, \ SpecHeight <SST_PIXELS, ZOOMER_CHAR_TABLE_HEIGHT+1> clr ss:[bp].SSA_count mov ss:[bp].SSA_updateMode, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_FIXED_SIZE ; bx is passed in as the handle to the block of UI to tweak mov si, offset PenGroup mov di, mask MF_STACK or mask MF_FIXUP_DS call ObjMessage mov ss:[bp].SSA_width, \ SpecWidth<SST_PIXELS, ZOOMER_CHAR_TABLE_WIDTH> clr ss:[bp].SSA_height mov si, offset HWRContextGroup mov di, mask MF_STACK or mask MF_FIXUP_DS call ObjMessage add sp, dx ; ; Set the vis bounds and fonts of the VisKeyboard, ; VisHWRGrid and CharTable objects ; mov ax, MSG_VIS_KEYBOARD_SET_TO_ZOOMER_SIZE mov si, offset KeyboardObj call ObjMessageFixupDS mov ax, MSG_VIS_HWR_GRID_SET_TO_ZOOMER_SIZE mov si, offset HWRGridObj call ObjMessageFixupDS mov bp, offset VisCharTableObjectTable mov si, cs:[bp] mov ax, MSG_VIS_CHAR_TABLE_SET_TO_ZOOMER_SIZE loopTop: call ObjMessageFixupDS inc bp inc bp ; next lptr mov si, cs:[bp] tst si jnz loopTop exit: .leave ret InitPenInputControlUISizes endp VisCharTableObjectTable lptr \ CharTableObj, CharTableSymbolsObj, CharTableInternationalObj, CharTableMathObj, CharTableCustomObj, 0 endif ; if INITFILE_KEYBOARD if not _GRAFFITI_UI ;not needed for _GRAFFITI_UI COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AddCorrectDisplayObj %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Adds the correct display to this object. CALLED BY: GLOBAL PASS: bx - block of children cx - PenInputDisplayType RETURN: nada DESTROYED: ax, cx, dx, bp, di, si PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 7/13/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AddCorrectDisplayObj proc near ; Ensure that no objects have been added to the content yet mov si, offset PenInputContent ;^lBX:SI <- VisContent EC < push cx > EC < mov ax, MSG_VIS_COUNT_CHILDREN > EC < call ObjMessageCall > EC < tst dx > EC < ERROR_NZ CONTROLLER_OBJECT_INTERNAL_ERROR > EC < pop cx > EC < cmp cx, PenInputDisplayType > EC < ERROR_AE BAD_PEN_INPUT_DISPLAY_TYPE > ; Add the appropriate child to the view and make it visible mov di, cx shl di ;DI <- offset into table of ; object to add mov cx, bx ;^lCX:DX <- child to add mov dx, cs:[childTable][di] EC < tst dx > EC < ERROR_Z BAD_PEN_INPUT_DISPLAY_TYPE > mov ax, MSG_VIS_ADD_CHILD mov bp, CCO_FIRST shl offset CCF_REFERENCE call ObjMessageFixupDS mov ax, MSG_VIS_MARK_INVALID movdw bxsi, cxdx mov cl, mask VOF_GEOMETRY_INVALID or \ mask VOF_WINDOW_INVALID or \ mask VOF_IMAGE_INVALID mov dl, VUM_NOW GOTO ObjMessageFixupDS AddCorrectDisplayObj endp if STYLUS_KEYBOARD childTable lptr \ KeyboardObj, 0, 0, 0, 0, 0, HWRGridObj, BigKeysObj, NumbersObj, PunctuationObj, 0, 0, 0, 0, 0, 0, 0, 0, 0 else childTable lptr \ KeyboardObj, CharTableObj, CharTableSymbolsObj, CharTableInternationalObj, CharTableMathObj, CharTableCustomObj, HWRGridObj, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 endif ; if _STYLUS_KEYBOARD .assert( (length childTable) eq PenInputDisplayType) COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLPenInputControlSetDisplay %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Sets the display of the pen input control to the current one. CALLED BY: GLOBAL PASS: *ds:si = OLPenInputControlClass cx = PenInputDisplayType of object to add RETURN: nada DESTROYED: ax, bx, dx, bp, si PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 7/13/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLPenInputControlSetDisplay method OLPenInputControlClass, MSG_GEN_PEN_INPUT_CONTROL_SET_DISPLAY .enter EC < cmp cx, PenInputDisplayType > EC < ERROR_AE BAD_PEN_INPUT_DISPLAY_TYPE > mov bp, si ; bp = self lptr call PI_GetFeaturesAndChildBlock test ax, mask GPICF_KEYBOARD or mask GPICF_CHAR_TABLE or mask GPICF_CHAR_TABLE_SYMBOLS or mask GPICF_CHAR_TABLE_INTERNATIONAL or mask GPICF_HWR_ENTRY_AREA or mask GPICF_CHAR_TABLE_CUSTOM jz exit if STYLUS_KEYBOARD ; ; Set the PIDT in the UI, because that is what everyone cares ; about. (Stylus only, because for everyone else they just change ; the UI itself to change keyboards). dlitwin 7/26/94 ; push ax, cx, dx, bp mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION clr dx call CallDisplayList pop ax, cx, dx, bp endif ; if STYLUS_KEYBOARD ; ; Set the various gen objects associated with the HWR Grid ; usable, if they exist. ; test ax, mask GPICF_HWR_ENTRY_AREA jz skipHWREntry push ax, cx, bp mov ax, MSG_GEN_SET_NOT_USABLE cmp cx, PIDT_HWR_ENTRY_AREA jnz setNotUsable mov ax, MSG_GEN_SET_USABLE ; ;Set the PenToolGroup usable/not usable when ;we switch to/from the HWR Grid display. ; setNotUsable: mov si, offset PenToolGroup mov dl, VUM_DELAYED_VIA_UI_QUEUE call ObjMessageFixupDS mov si, offset HWRContextGroup mov dl, VUM_DELAYED_VIA_UI_QUEUE call ObjMessageFixupDS mov si, offset HWRGridTools mov dl, VUM_DELAYED_VIA_UI_QUEUE call ObjMessageFixupDS pop ax, cx, bp ; ; Remove any existing displays ; First, find the first (only) child of the content ; skipHWREntry: push cx mov ax, MSG_VIS_FIND_CHILD_AT_POSITION clr cx ;Find first child mov si, offset PenInputContent ;^lBX:SI <- VisContent push bp ; save self lptr call ObjMessageCall ;^lCX:DX <- Vis Child pop bp ; bp = self lptr jc noChildren ; ; Remove the child. ; mov ax, MSG_VIS_REMOVE movdw bxsi, cxdx mov dl, VUM_MANUAL call ObjMessageFixupDS noChildren: pop cx ; ; Add the display object ; push cx push bp ; preserve our obj lptr call AddCorrectDisplayObj pop si ; restore our obj lptr mov ax, MSG_GEN_RESET_TO_INITIAL_SIZE mov dl, VUM_DELAYED_VIA_UI_QUEUE call ObjCallInstanceNoLock pop cx ; cx = PenInputDisplayType ; ; tell Flow object whether or not the window should now receive ; ink input sub cx, PIDT_HWR_ENTRY_AREA ; cx = zero if HWR, non-zero if others clr di ; send message call RegisterNoInkWin exit: .leave ret OLPenInputControlSetDisplay endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PI_GetFeaturesAndChildBlock %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Gets the features and childBlock of the PenInputControl. CALLED BY: OLPenInputControlSetDisplay PASS: *ds:si = OLPenInputControlClass RETURN: ax = features of the PIC bx = hptr of UI block DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- dlitwin 5/11/94 Added this header %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ PI_GetFeaturesAndChildBlock proc near .enter EC < push es, di > EC < mov di, segment OLPenInputControlClass > EC < mov es, di > EC < mov di, offset OLPenInputControlClass > EC < call ObjIsObjectInClass > EC < ERROR_NC CONTROLLER_OBJECT_INTERNAL_ERROR > EC < pop es, di > mov ax, TEMP_GEN_CONTROL_INSTANCE call ObjVarDerefData ;ds:bx = data mov ax, ds:[bx].TGCI_features mov bx, ds:[bx].TGCI_childBlock .leave ret PI_GetFeaturesAndChildBlock endp endif ; if (not _GRAFFITI_UI) COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CallDisplayList %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Calls the current display list. CALLED BY: GLOBAL PASS: ax, cx, dx, bp - message params bx - child block RETURN: nada DESTROYED: nada PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 2/ 8/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if not _GRAFFITI_UI ;not needed for _GRAFFITI_UI CallDisplayList proc near uses si .enter EC < call ECCheckMemHandle > mov si, offset TitlePenDisplayList call ObjMessageCall .leave ret CallDisplayList endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLPenInputControlGetDisplay %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get the currently displayed keyboard CALLED BY: GLOBAL PASS: nada RETURN: cx - PenInputDisplayType carry - set on error, cx = invalid DESTROYED: ax, dx, bp PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 12/01/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLPenInputControlGetDisplay method OLPenInputControlClass, MSG_GEN_PEN_INPUT_CONTROL_GET_DISPLAY if _GRAFFITI_UI ; ; return GRAFFITI type ; mov cx, PIDT_GRAFFITI clc else .enter ; Ask child for the current keyboard ; call PI_GetFeaturesAndChildBlock tst bx stc jz exit mov ax, MSG_GEN_ITEM_GROUP_GET_SELECTION call CallDisplayList mov_tr cx, ax ; CX <- PenInputDisplayType clc exit: .leave endif ret OLPenInputControlGetDisplay endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLPenInputControlAddToGCNLists %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Add the floating keyboard from any GCN lists it may reside on. CALLED BY: GLOBAL PASS: *ds:si - OLPenInputControlClass object ax - message # RETURN: nada DESTROYED: ax, cx, dx, bp PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: No need to call our superclass, as we are implemented in the SPUI and our superclass won't have anything to do with controllers. We only get called through the magic of the Controller's GCBF_SPECIFIC_UI flag. REVISION HISTORY: Name Date Description ---- ---- ----------- atw 4/16/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLPenInputControlAddToGCNLists method OLPenInputControlClass, MSG_GEN_CONTROL_ADD_TO_GCN_LISTS .enter ; ; The floating keyboard resides on the "ALWAYS_INTERACTABLE" ; GCN list, so the user can click on it while modal boxes are ; on screen. ; mov ax, MSG_META_GCN_LIST_ADD mov dx, size GCNListParams sub sp, dx mov bp, sp mov cx, ds:[LMBH_handle] movdw ss:[bp].GCNLP_optr, cxsi mov ss:[bp].GCNLP_ID.GCNLT_manuf, MANUFACTURER_ID_GEOWORKS mov ss:[bp].GCNLP_ID.GCNLT_type, GAGCNLT_ALWAYS_INTERACTABLE_WINDOWS call UserCallApplication add sp, size GCNListParams .leave ret OLPenInputControlAddToGCNLists endp if not _GRAFFITI_UI ;not needed for _GRAFFITI_UI COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLPenInputControlMoveResizeWin %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: This method notifies the currently focused window whenever CALLED BY: GLOBAL PASS: nada RETURN: nada DESTROYED: nada PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 4/20/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLPenInputControlMoveResizeWin method OLPenInputControlClass, MSG_VIS_MOVE_RESIZE_WIN mov di, offset OLPenInputControlClass call ObjCallSuperNoLock ; ; We are the floating keyboard, so get the position of the window ; and inform the focus window, so they can move us to our correct ; position when they get the focus. ; mov ax, MSG_VIS_GET_POSITION call ObjCallInstanceNoLock ;CX <- left edge of box ;DX <- top edge of box push si mov ax, MSG_GEN_SET_KBD_POSITION clrdw bxsi mov di, mask MF_RECORD call ObjMessage pop si mov cx, di mov dx, TO_APP_FOCUS mov ax, MSG_META_SEND_CLASSED_EVENT GOTO ObjCallInstanceNoLock OLPenInputControlMoveResizeWin endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VisCachedGStateVisOpen %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Handles vis open (allocates a cached gstate) CALLED BY: GLOBAL PASS: stuff for vis open RETURN: nada DESTROYED: nada PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 7/13/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VisCachedGStateVisOpen method VisCachedGStateClass, MSG_VIS_OPEN .enter mov di, offset VisCachedGStateClass call ObjCallSuperNoLock mov ax, MSG_VIS_VUP_CREATE_GSTATE call ObjCallSuperNoLock jnc exit ;If no gstate available mov di, ds:[si] add di, ds:[di].VisCachedGState_offset mov ds:[di].VCGSI_gstate, bp exit: .leave ret VisCachedGStateVisOpen endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VisCachedGStateVisClose %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Handles vis close (allocates a cached gstate) CALLED BY: GLOBAL PASS: stuff for vis close RETURN: nada DESTROYED: nada PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 7/13/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VisCachedGStateVisClose method VisCachedGStateClass, MSG_VIS_CLOSE mov di, offset VisCachedGStateClass call ObjCallSuperNoLock mov di, ds:[si] add di, ds:[di].VisCachedGState_offset clr ax xchg ax, ds:[di].VCGSI_gstate tst ax jz exit mov_tr di, ax GOTO GrDestroyState exit: ret VisCachedGStateVisClose endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NotifyEnabledStateGenViewSpecNotifyEnabled %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: When the view becomes enabled, it sets the enabled flag on the content. CALLED BY: GLOBAL PASS: *ds:si = GenView object RETURN: carry = set if visual state changed DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 4/15/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ NotifyEnabledStateGenViewSpecNotifyEnabled method NotifyEnabledStateGenViewClass, MSG_SPEC_NOTIFY_ENABLED, MSG_SPEC_NOTIFY_NOT_ENABLED .enter mov di, offset NotifyEnabledStateGenViewClass call ObjCallSuperNoLock jnc noStateChange ;If we aren't changing our ; enabled state, branch mov di, ds:[si] add di, ds:[di].GenView_offset movdw bxsi, ds:[di].GVI_content mov ax, MSG_VIS_INVALIDATE mov dl, VUM_NOW call ObjMessageFixupDS stc ;Signify that we are changing ; our fully-enabled state noStateChange: .leave ret NotifyEnabledStateGenViewSpecNotifyEnabled endp endif ; if (not _GRAFFITI_UI) COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLPenInputControlScanFeatureHints %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: This nukes all features if the system is not pen based. CALLED BY: GLOBAL PASS: cx - GenControlUIType dx:bp - ptr to GenControlScanInfo struct to fill in RETURN: nada DESTROYED: nada PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 10/ 4/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLPenInputControlScanFeatureHints method OLPenInputControlClass, MSG_GEN_CONTROL_SCAN_FEATURE_HINTS .enter mov es, dx mov di, bp mov ax, ATTR_GEN_PEN_INPUT_CONTROL_MAKE_VISIBLE_ON_ALL_SYSTEMS call ObjVarFindData jc exit call FlowGetUIButtonFlags test al, mask UIBF_NO_KEYBOARD jnz exit call UserGetFloatingKbdEnabledStatus tst ax jnz exit ; We are not pen based, so nuke the features mov es:[di].GCSI_appProhibited, mask GPICToolboxFeatures cmp cx, GCUIT_TOOLBOX jz exit mov es:[di].GCSI_appProhibited, mask GPICFeatures exit: .leave ret OLPenInputControlScanFeatureHints endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLPICVisOpen %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Handles vis open (add keyboard window to no-ink list) and changing the window layer if starting up from state so we don't come up behind everything. CALLED BY: MSG_VIS_OPEN PASS: *ds:si = OLPenInputControlClass object ds:di = OLPenInputControlClass instance data ds:bx = OLPenInputControlClass object (same as *ds:si) es = segment of OLPenInputControlClass ax = message # bp = 0 if top window, else window for object to open on RETURN: nothing DESTROYED: ax, cx, dx, bp SIDE EFFECTS: PSEUDO CODE/STRATEGY: If not using HWR grid, add keyboard window to no-ink list. REVISION HISTORY: Name Date Description ---- ---- ----------- AY 5/18/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLPICVisOpen method dynamic OLPenInputControlClass, MSG_VIS_OPEN .enter push si mov di, offset OLPenInputControlClass call ObjCallSuperNoLock if not _GRAFFITI_UI ;not needed for _GRAFFITI_UI ; add view's window to no-ink list if not using HWR grid mov ax, MSG_GEN_PEN_INPUT_CONTROL_GET_DISPLAY call ObjCallInstanceNoLock ; rtn cx = PenInputDisplayType jc afterHWRWinStuff sub cx, PIDT_HWR_ENTRY_AREA je afterHWRWinStuff clr di call RegisterNoInkWin afterHWRWinStuff: endif pop si mov ax, MSG_GEN_APPLICATION_GET_STATE call UserCallApplication test ax, mask AS_ATTACHING jz exit mov ax, MSG_VIS_QUERY_WINDOW call ObjCallInstanceNoLock mov di, cx mov si, WIT_PARENT_WIN call WinGetInfo mov di, ax mov ax, mask WPF_LAYER or 0 ; leave priority alone call GeodeGetProcessHandle mov dx, bx call WinChangePriority exit: .leave ret OLPICVisOpen endm if not _GRAFFITI_UI ;not needed for _GRAFFITI_UI COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLPICVisClose %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Handles vis close (remove keyboard window from no-ink list) CALLED BY: MSG_VIS_CLOSE PASS: *ds:si = OLPenInputControlClass object ds:di = OLPenInputControlClass instance data ds:bx = OLPenInputControlClass object (same as *ds:si) es = segment of OLPenInputControlClass ax = message # RETURN: nothing DESTROYED: ax, cx, dx, bp SIDE EFFECTS: PSEUDO CODE/STRATEGY: If not using HWR grid, remove keyboard window from no-ink list. REVISION HISTORY: Name Date Description ---- ---- ----------- AY 5/18/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLPICVisClose method dynamic OLPenInputControlClass, MSG_VIS_CLOSE ; if we're using HWR grid, no need to remove window because it wasn't ; on the list anyway. (No need to waste time.) mov ax, MSG_GEN_PEN_INPUT_CONTROL_GET_DISPLAY call ObjCallInstanceNoLock ; rtn cx = PenInputDisplayType jc noNeedToRemove sub cx, PIDT_HWR_ENTRY_AREA je noNeedToRemove ; no need to remove if HWR grid ; remove view's window from list push si ; save self lptr clr cx ; remove from list mov di, mask MF_CALL or mask MF_FIXUP_DS ; make it a call such that passed ; handle remains valid when this msg ; reaches Flow object call RegisterNoInkWin pop si ; *ds:si = self noNeedToRemove: mov ax, MSG_VIS_CLOSE mov di, offset OLPenInputControlClass GOTO ObjCallSuperNoLock OLPICVisClose endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% RegisterNoInkWin %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Add/remove window from no-ink list maintained by flow object CALLED BY: INTERNAL, OLPenInputControlSetDisplay, OLPICVisOpen, OLPICVisClose PASS: *ds:si = OLPenInputControlClass object cx = non-zero to add, zero to remove di = MessageFlags to pass to UserCallFlow RETURN: nothing DESTROYED: bx, si May destroy: ax, cx, dx, bp, ds, es (depends on passed di) SIDE EFFECTS: PSEUDO CODE/STRATEGY: If the window for the keyboard is not build out yet, skip adding. (This happens sometimes when the OLPenInputControl object receives MSG_GEN_PEN_INPUT_CONTROL_SET_DISPLAY before MSG_VIS_OPEN.) REVISION HISTORY: Name Date Description ---- ---- ----------- AY 5/18/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ RegisterNoInkWin proc near push cx, di ; get view's window that keyboard is in call PI_GetFeaturesAndChildBlock ; rtn bx = child block hptr mov si, offset PenInputView mov ax, MSG_GEN_VIEW_GET_WINDOW call ObjMessageCall ; rtn cx = window handle mov ax, MSG_FLOW_REGISTER_NO_INK_WIN mov bp, cx ; bp = window handle pop cx, di ; Sometimes MSG_GEN_PEN_INPUT_CONTROL_SET_DISPLAY is received before ; the window is built out when the keyboard first comes on screen. ; If this is the case, just skip adding. The window will be added ; when MSG_VIS_OPEN is handled later anyway. tst bp jz done ; window not built yet, skip. call UserCallFlow done: ret RegisterNoInkWin endp if not STYLUS_KEYBOARD COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLPenInputControlResetConstrain %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: In Motif we set up a WinConstrainType of "always on screen" so when we position at the bottom of the screen it will be just where we want it (i.e. not hanging off the screen). Before we initiate it again we need to remove this constrain, so it can once again be moved off screen by the user. Stylus doesn't use this because it is permanently on screen. CALLED BY: MSG_GEN_PEN_INPUT_CONTROL_RESET_CONSTRAIN PASS: *ds:si = OLPenInputControlClass object RETURN: nothing DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- dlitwin 6/14/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLPenInputControlResetConstrain method dynamic OLPenInputControlClass, MSG_GEN_PEN_INPUT_CONTROL_RESET_CONSTRAIN uses ax, cx, dx, bp .enter mov ax, MSG_GEN_SET_WIN_CONSTRAIN mov dx, (WCT_KEEP_PARTIALLY_VISIBLE shl 8) or VUM_MANUAL call ObjCallInstanceNoLock .leave ret OLPenInputControlResetConstrain endm endif ; if (not STYLUS_KEYBOARD) endif ; if (not _GRAFFITI_UI) COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLPenInputControlDetach %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Remove ourselves from the active list. CALLED BY: MSG_META_DETACH PASS: *ds:si = OLPenInputControlClass object ds:di = OLPenInputControlClass instance data es = segment of OLPenInputControlClass RETURN: nothing DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- dlitwin 6/30/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLPenInputControlDetach method dynamic OLPenInputControlClass, MSG_META_DETACH uses ax, cx, dx, bp .enter ; ; Remove ourselves from any GCNLists we are on. We have the ; GCBF_ALWAYS_ON_GCN_LIST set so we aren't removed from these ; lists when just being set not interactable, but this time ; we really do want to be removed, so we send the message manually ; because the GenControl handler will check the flag and leave ; us on otherwise. ; mov ax, MSG_GEN_CONTROL_REMOVE_FROM_GCN_LISTS call ObjCallInstanceNoLock .leave mov di, offset OLPenInputControlClass call ObjCallSuperNoLock ret OLPenInputControlDetach endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLPenInputControlRemoveFromGCNLists %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Remove the object from the active list. The active list isn't like the normal lists that can be set up in the GenControlBuildInfo structure, and so we have to add it and remove it manually, so we do so when the others are being removed. CALLED BY: MSG_GEN_CONTROL_REMOVE_FROM_GCN_LISTS PASS: *ds:si = OLPenInputControlClass object es = segment of OLPenInputControlClass RETURN: nothing DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: No need to call our superclass, as we are implemented in the SPUI and our superclass won't have anything to do with controllers. We only get called through the magic of the Controller's GCBF_SPECIFIC_UI flag. REVISION HISTORY: Name Date Description ---- ---- ----------- dlitwin 7/ 1/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLPenInputControlRemoveFromGCNLists method dynamic OLPenInputControlClass, MSG_GEN_CONTROL_REMOVE_FROM_GCN_LISTS uses ax, cx, dx, bp .enter mov ax, MSG_META_GCN_LIST_REMOVE mov dx, size GCNListParams sub sp, dx mov bp, sp mov cx, ds:[LMBH_handle] movdw ss:[bp].GCNLP_optr, cxsi mov ss:[bp].GCNLP_ID.GCNLT_manuf, MANUFACTURER_ID_GEOWORKS mov ss:[bp].GCNLP_ID.GCNLT_type, MGCNLT_ACTIVE_LIST or mask GCNLTF_SAVE_TO_STATE call UserCallApplication mov ax, MSG_META_GCN_LIST_REMOVE mov dx, size GCNListParams mov bp, sp mov ss:[bp].GCNLP_ID.GCNLT_type, GAGCNLT_ALWAYS_INTERACTABLE_WINDOWS call UserCallApplication add sp, size GCNListParams .leave ret OLPenInputControlRemoveFromGCNLists endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BoxedInteractionVisDraw %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draw box around interaction if monochrome display CALLED BY: MSG_VIS_DRAW PASS: *ds:si = BoxedInteractionClass object ds:di = BoxedInteractionClass instance data ds:bx = BoxedInteractionClass object (same as *ds:si) es = segment of BoxedInteractionClass ax = message # cl = DrawFlags: DF_EXPOSED set if GState is set to update window ^hbp = GState to draw through. RETURN: nothing DESTROYED: ax, cx, dx, bp SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- JS 5/12/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GenPenInputControlCode ends
SFX_Cry00_1_Ch4: dutycycle 245 squarenote 4, 15, 3, 1816 squarenote 15, 14, 5, 1944 squarenote 8, 9, 1, 1880 endchannel SFX_Cry00_1_Ch5: dutycycle 160 squarenote 5, 11, 3, 1800 squarenote 15, 12, 5, 1928 squarenote 8, 7, 1, 1864 endchannel SFX_Cry00_1_Ch7: noisenote 3, 10, 1, 28 noisenote 14, 9, 4, 44 noisenote 8, 8, 1, 28 endchannel
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "remoting/base/rate_counter.h" namespace remoting { RateCounter::RateCounter(base::TimeDelta time_window) : time_window_(time_window), sum_(0) { } RateCounter::~RateCounter() { } void RateCounter::Record(int64 value) { base::Time current_time = base::Time::Now(); Evict(current_time); base::AutoLock auto_lock(lock_); sum_ += value; data_points_.push(std::make_pair(current_time, value)); } double RateCounter::Rate() { Evict(base::Time::Now()); base::AutoLock auto_lock(lock_); return static_cast<double>(base::Time::kMillisecondsPerSecond) * sum_ / time_window_.InMilliseconds(); } void RateCounter::Evict(base::Time current_time) { base::AutoLock auto_lock(lock_); // Remove data points outside of the window. base::Time window_start = current_time - time_window_; while (!data_points_.empty()) { if (data_points_.front().first > window_start) break; sum_ -= data_points_.front().second; data_points_.pop(); } } } // namespace remoting
/// \file // Range v3 library // // Copyright Eric Niebler 2014-present // // Use, modification and distribution is subject to the // Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Project home: https://github.com/ericniebler/range-v3 // #ifndef RANGES_V3_VIEW_JOIN_HPP #define RANGES_V3_VIEW_JOIN_HPP #include <type_traits> #include <utility> #include <meta/meta.hpp> #include <range/v3/range_fwd.hpp> #include <range/v3/functional/bind_back.hpp> #include <range/v3/iterator/default_sentinel.hpp> #include <range/v3/range/access.hpp> #include <range/v3/range/primitives.hpp> #include <range/v3/range/traits.hpp> #include <range/v3/range_for.hpp> #include <range/v3/utility/static_const.hpp> #include <range/v3/utility/variant.hpp> #include <range/v3/view/all.hpp> #include <range/v3/view/facade.hpp> #include <range/v3/view/single.hpp> #include <range/v3/view/view.hpp> #include <range/v3/detail/disable_warnings.hpp> namespace ranges { /// \cond namespace detail { // Compute the cardinality of a joined range constexpr cardinality join_cardinality_( cardinality Outer, cardinality Inner, cardinality Joiner = static_cast<cardinality>(0)) noexcept { return Outer == infinite || Inner == infinite || (Joiner == infinite && Outer != 0 && Outer != 1) ? infinite : Outer == unknown || Inner == unknown || (Joiner == unknown && Outer != 0 && Outer != 1) ? unknown : Outer == finite || Inner == finite || (Joiner == finite && Outer != 0 && Outer != 1) ? finite : static_cast<cardinality>( Outer * Inner + (Outer == 0 ? 0 : (Outer - 1) * Joiner)); } template<typename Range> constexpr cardinality join_cardinality() noexcept { return detail::join_cardinality_( range_cardinality<Range>::value, range_cardinality<range_reference_t<Range>>::value); } template<typename Range, typename JoinRange> constexpr cardinality join_cardinality() noexcept { return detail::join_cardinality_( range_cardinality<Range>::value, range_cardinality<range_reference_t<Range>>::value, range_cardinality<JoinRange>::value); } template<typename Inner> struct store_inner_ { views::all_t<Inner> inner_ = views::all_t<Inner>(); constexpr views::all_t<Inner> & update_inner_(Inner && inner) { return (inner_ = views::all(static_cast<Inner &&>(inner))); } constexpr views::all_t<Inner> & get_inner_(ignore_t) noexcept { return inner_; } }; struct pass_thru_inner_ { // Intentionally promote xvalues to lvalues here: template<typename Inner> static constexpr Inner & update_inner_(Inner && inner) noexcept { return inner; } template<typename OuterIt> static constexpr decltype(auto) get_inner_(OuterIt && outer_it) { return *outer_it; } }; template<typename Rng> using join_view_inner = if_then_t<!std::is_reference<range_reference_t<Rng>>::value, store_inner_<range_reference_t<Rng>>, pass_thru_inner_>; // clang-format off template<typename I> CPP_concept_fragment(has_member_arrow_, requires(I i) // ( i.operator->() )); template<typename I> CPP_concept_bool has_arrow_ = input_iterator<I> && (std::is_pointer<I>::value || CPP_fragment(detail::has_member_arrow_, I)); // clang-format on } // namespace detail /// \endcond /// \addtogroup group-views /// @{ // Join a range of ranges template<typename Rng> struct RANGES_EMPTY_BASES join_view : view_facade<join_view<Rng>, detail::join_cardinality<Rng>()> , private detail::join_view_inner<Rng> { CPP_assert(input_range<Rng> && view_<Rng>); CPP_assert(input_range<range_reference_t<Rng>>); CPP_assert(std::is_reference<range_reference_t<Rng>>::value || view_<range_reference_t<Rng>>); join_view() = default; explicit join_view(Rng rng) : outer_(views::all(std::move(rng))) {} // Not to spec CPP_member static constexpr auto size() -> CPP_ret(std::size_t)( // requires(detail::join_cardinality<Rng>() >= 0)) { return static_cast<std::size_t>(detail::join_cardinality<Rng>()); } // Not to spec CPP_member constexpr auto CPP_fun(size)()(requires(detail::join_cardinality<Rng>() < 0) && (range_cardinality<Rng>::value >= 0) && forward_range<Rng> && sized_range<range_reference_t<Rng>>) { range_size_t<range_reference_t<Rng>> n = 0; RANGES_FOR(auto && inner, outer_) n += ranges::size(inner); return n; } // // ericniebler/stl2#605 constexpr Rng base() const { return outer_; } private: friend range_access; Rng outer_{}; template<bool Const> struct cursor { private: using Parent = detail::if_then_t<Const, join_view const, join_view>; using COuter = detail::if_then_t<Const, Rng const, Rng>; using CInner = range_reference_t<COuter>; using ref_is_glvalue = std::is_reference<CInner>; Parent * rng_ = nullptr; iterator_t<COuter> outer_it_{}; iterator_t<CInner> inner_it_{}; void satisfy() { for(; outer_it_ != ranges::end(rng_->outer_); ++outer_it_) { auto & inner = rng_->update_inner_(*outer_it_); inner_it_ = ranges::begin(inner); if(inner_it_ != ranges::end(inner)) return; } if(RANGES_CONSTEXPR_IF(ref_is_glvalue::value)) inner_it_ = iterator_t<CInner>(); } public: using single_pass = meta::bool_<single_pass_iterator_<iterator_t<COuter>> || single_pass_iterator_<iterator_t<CInner>> || !ref_is_glvalue::value>; cursor() = default; template<typename BeginOrEnd> constexpr cursor(Parent * rng, BeginOrEnd begin_or_end) : rng_{rng} , outer_it_(begin_or_end(rng->outer_)) { satisfy(); } CPP_template(bool Other)( // requires Const && (!Other) && convertible_to<iterator_t<Rng>, iterator_t<COuter>> && convertible_to<iterator_t<range_reference_t<Rng>>, iterator_t<CInner>>) // constexpr cursor(cursor<Other> that) : rng_(that.rng_) , outer_it_(std::move(that.outer_it_)) , inner_it_(std::move(that.inner_it_)) {} CPP_member constexpr auto arrow() -> CPP_ret(iterator_t<CInner>)( // requires detail::has_arrow_<iterator_t<CInner>>) { return inner_it_; } constexpr bool equal(default_sentinel_t) const { return outer_it_ == ranges::end(rng_->outer_); } CPP_member constexpr auto equal(cursor const & that) const -> CPP_ret(bool)( // requires ref_is_glvalue::value && equality_comparable< iterator_t<COuter>> && equality_comparable<iterator_t<CInner>>) { return outer_it_ == that.outer_it_ && inner_it_ == that.inner_it_; } constexpr void next() { auto && inner_rng = rng_->get_inner_(outer_it_); if(++inner_it_ == ranges::end(inner_rng)) { ++outer_it_; satisfy(); } } CPP_member constexpr auto prev() -> CPP_ret(void)( // requires ref_is_glvalue::value && bidirectional_range<COuter> && bidirectional_range<CInner> && common_range<CInner>) // ericniebler/stl2#606 { if(outer_it_ == ranges::end(rng_->outer_)) inner_it_ = ranges::end(*--outer_it_); while(inner_it_ == ranges::begin(*outer_it_)) inner_it_ = ranges::end(*--outer_it_); --inner_it_; } // clang-format off constexpr auto CPP_auto_fun(read)()(const) ( return *inner_it_ ) constexpr auto CPP_auto_fun(move)()(const) ( return iter_move(inner_it_) ) // clang-format on }; static constexpr bool use_const_always() noexcept { return simple_view<Rng>() && std::is_reference<range_reference_t<Rng>>::value; } struct end_cursor_fn { constexpr auto operator()(join_view * this_, std::true_type) const { return cursor<use_const_always()>{this_, ranges::end}; } constexpr auto operator()(join_view *, std::false_type) const { return default_sentinel_t{}; } }; struct cend_cursor_fn { constexpr auto operator()(join_view const * this_, std::true_type) const { return cursor<true>{this_, ranges::end}; } constexpr auto operator()(join_view const *, std::false_type) const { return default_sentinel_t{}; } }; constexpr cursor<use_const_always()> begin_cursor() { return {this, ranges::begin}; } template<bool Const = true> constexpr auto begin_cursor() const -> CPP_ret(cursor<Const>)( // requires Const && input_range<meta::const_if_c<Const, Rng>> && std::is_reference<range_reference_t<meta::const_if_c<Const, Rng>>>::value) { return {this, ranges::begin}; } constexpr auto end_cursor() { using cond = meta::bool_<std::is_reference<range_reference_t<Rng>>::value && forward_range<Rng> && forward_range<range_reference_t<Rng>> && common_range<Rng> && common_range<range_reference_t<Rng>>>; return end_cursor_fn{}(this, cond{}); } template<bool Const = true> constexpr auto CPP_fun(end_cursor)()( const requires Const && input_range<meta::const_if_c<Const, Rng>> && std::is_reference<range_reference_t<meta::const_if_c<Const, Rng>>>::value) { using CRng = meta::const_if_c<Const, Rng>; using cond = meta::bool_<std::is_reference<range_reference_t<CRng>>::value && forward_range<CRng> && forward_range<range_reference_t<CRng>> && common_range<CRng> && common_range<range_reference_t<CRng>>>; return cend_cursor_fn{}(this, cond{}); } }; // Join a range of ranges, inserting a range of values between them. // TODO: Support const iteration when range_reference_t<Rng> is a true reference. template<typename Rng, typename ValRng> struct join_with_view : view_facade<join_with_view<Rng, ValRng>, detail::join_cardinality<Rng, ValRng>()> { CPP_assert(input_range<Rng>); CPP_assert(input_range<range_reference_t<Rng>>); CPP_assert(forward_range<ValRng>); CPP_assert( common_with<range_value_t<range_reference_t<Rng>>, range_value_t<ValRng>>); CPP_assert(semiregular<common_type_t<range_value_t<range_reference_t<Rng>>, range_value_t<ValRng>>>); join_with_view() = default; join_with_view(Rng rng, ValRng val) : outer_(views::all(std::move(rng))) , val_(views::all(std::move(val))) {} CPP_member static constexpr auto size() -> CPP_ret(std::size_t)( // requires(detail::join_cardinality<Rng, ValRng>() >= 0)) { return static_cast<std::size_t>(detail::join_cardinality<Rng, ValRng>()); } CPP_member auto CPP_fun(size)()(const requires(detail::join_cardinality<Rng, ValRng>() < 0) && (range_cardinality<Rng>::value >= 0) && forward_range<Rng> && sized_range<range_reference_t<Rng>> && sized_range<ValRng>) { range_size_t<range_reference_t<Rng>> n = 0; RANGES_FOR(auto && inner, outer_) n += ranges::size(inner); return n + (range_cardinality<Rng>::value == 0 ? 0 : ranges::size(val_) * (range_cardinality<Rng>::value - 1)); } private: friend range_access; using Outer = views::all_t<Rng>; // Intentionally promote xvalues to lvalues here: using Inner = views::all_t<range_reference_t<Outer> &>; Outer outer_{}; Inner inner_{}; views::all_t<ValRng> val_{}; class cursor { join_with_view * rng_ = nullptr; iterator_t<Outer> outer_it_{}; variant<iterator_t<ValRng>, iterator_t<Inner>> cur_{}; void satisfy() { while(true) { if(cur_.index() == 0) { if(ranges::get<0>(cur_) != ranges::end(rng_->val_)) break; // Intentionally promote xvalues to lvalues here: auto && tmp = *outer_it_; rng_->inner_ = views::all(tmp); ranges::emplace<1>(cur_, ranges::begin(rng_->inner_)); } else { if(ranges::get<1>(cur_) != ranges::end(rng_->inner_)) break; if(++outer_it_ == ranges::end(rng_->outer_)) break; ranges::emplace<0>(cur_, ranges::begin(rng_->val_)); } } } public: using value_type = common_type_t<range_value_t<Inner>, range_value_t<ValRng>>; using reference = common_reference_t<range_reference_t<Inner>, range_reference_t<ValRng>>; using rvalue_reference = common_reference_t<range_rvalue_reference_t<Inner>, range_rvalue_reference_t<ValRng>>; using single_pass = std::true_type; cursor() = default; cursor(join_with_view * rng) : rng_{rng} , outer_it_(ranges::begin(rng->outer_)) { if(outer_it_ != ranges::end(rng->outer_)) { // Intentionally promote xvalues to lvalues here: auto && tmp = *outer_it_; rng->inner_ = views::all(tmp); ranges::emplace<1>(cur_, ranges::begin(rng->inner_)); satisfy(); } } bool equal(default_sentinel_t) const { return outer_it_ == ranges::end(rng_->outer_); } void next() { // visit(cur_, [](auto& it){ ++it; }); if(cur_.index() == 0) { auto & it = ranges::get<0>(cur_); RANGES_ASSERT(it != ranges::end(rng_->val_)); ++it; } else { auto & it = ranges::get<1>(cur_); RANGES_ASSERT(it != ranges::end(rng_->inner_)); ++it; } satisfy(); } reference read() const { // return visit(cur_, [](auto& it) -> reference { return *it; }); if(cur_.index() == 0) return *ranges::get<0>(cur_); else return *ranges::get<1>(cur_); } rvalue_reference move() const { // return visit(cur_, [](auto& it) -> rvalue_reference { return // iter_move(it); }); if(cur_.index() == 0) return iter_move(ranges::get<0>(cur_)); else return iter_move(ranges::get<1>(cur_)); } }; cursor begin_cursor() { return {this}; } }; namespace views { /// \cond // Don't forget to update views::for_each whenever this set // of concepts changes // clang-format off template<typename Rng> CPP_concept_fragment(joinable_range_, requires()(0) && input_range<range_reference_t<Rng>> && (std::is_reference<range_reference_t<Rng>>::value || view_<range_reference_t<Rng>>) ); template<typename Rng> CPP_concept_bool joinable_range = viewable_range<Rng> && input_range<Rng> && CPP_fragment(views::joinable_range_, Rng); template<typename Rng, typename ValRng> CPP_concept_fragment(joinable_with_range_, requires()(0) && common_with<range_value_t<ValRng>, range_value_t<range_reference_t<Rng>>> && semiregular< common_type_t< range_value_t<ValRng>, range_value_t<range_reference_t<Rng>>>> && common_reference_with< range_reference_t<ValRng>, range_reference_t<range_reference_t<Rng>>> && common_reference_with< range_rvalue_reference_t<ValRng>, range_rvalue_reference_t<range_reference_t<Rng>>> ); template<typename Rng, typename ValRng> CPP_concept_bool joinable_with_range = joinable_range<Rng> && viewable_range<ValRng> && forward_range<ValRng> && CPP_fragment(views::joinable_with_range_, Rng, ValRng); // clang-format on /// \endcond struct cpp20_join_fn { template<typename Rng> auto operator()(Rng && rng) const -> CPP_ret(join_view<all_t<Rng>>)( // requires joinable_range<Rng>) { return join_view<all_t<Rng>>{all(static_cast<Rng &&>(rng))}; } }; struct join_base_fn : cpp20_join_fn { private: template<typename Rng> using inner_value_t = range_value_t<range_reference_t<Rng>>; public: using cpp20_join_fn::operator(); template<typename Rng> auto operator()(Rng && rng, inner_value_t<Rng> v) const -> CPP_ret(join_with_view<all_t<Rng>, single_view<inner_value_t<Rng>>>)( // requires joinable_with_range<Rng, single_view<inner_value_t<Rng>>>) { return {all(static_cast<Rng &&>(rng)), single(std::move(v))}; } template<typename Rng, typename ValRng> auto operator()(Rng && rng, ValRng && val) const -> CPP_ret(join_with_view<all_t<Rng>, all_t<ValRng>>)( // requires joinable_with_range<Rng, ValRng>) { return {all(static_cast<Rng &&>(rng)), all(static_cast<ValRng &&>(val))}; } /// \cond template<typename Rng, typename T> auto operator()(Rng && rng, detail::reference_wrapper_<T> r) const -> invoke_result_t<join_base_fn, Rng, T &> { return (*this)(static_cast<Rng &&>(rng), r.get()); } /// \endcond }; struct join_bind_fn { template<typename T> constexpr auto CPP_fun(operator())(T && t)(const // requires(!joinable_range<T>)) // TODO: underconstrained { return make_view_closure(bind_back(join_base_fn{}, static_cast<T &&>(t))); } template<typename T> constexpr auto CPP_fun(operator())(T & t)(const // requires(!joinable_range<T &>) && range<T &>) { return make_view_closure(bind_back(join_base_fn{}, detail::reference_wrapper_<T>(t))); } }; struct RANGES_EMPTY_BASES join_fn : join_base_fn, join_bind_fn { using join_base_fn::operator(); using join_bind_fn::operator(); }; /// \relates join_fn /// \ingroup group-views RANGES_INLINE_VARIABLE(view_closure<join_fn>, join) } // namespace views /// @} #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 CPP_template(typename Rng)( // requires views::joinable_range<Rng>) // explicit join_view(Rng &&) ->join_view<views::all_t<Rng>>; CPP_template(typename Rng, typename ValRng)( // requires views::joinable_with_range<Rng, ValRng>) // explicit join_with_view(Rng &&, ValRng &&) ->join_with_view<views::all_t<Rng>, views::all_t<ValRng>>; #endif namespace cpp20 { namespace views { RANGES_INLINE_VARIABLE( ranges::views::view_closure<ranges::views::cpp20_join_fn>, join) } CPP_template(typename Rng)( // requires input_range<Rng> && view_<Rng> && input_range<iter_reference_t<iterator_t<Rng>>> && (std::is_reference<iter_reference_t<iterator_t<Rng>>>::value || view_<iter_value_t<iterator_t<Rng>>>)) // using join_view = ranges::join_view<Rng>; } // namespace cpp20 } // namespace ranges #include <range/v3/detail/reenable_warnings.hpp> #include <range/v3/detail/satisfy_boost_range.hpp> RANGES_SATISFY_BOOST_RANGE(::ranges::join_view) RANGES_SATISFY_BOOST_RANGE(::ranges::join_with_view) #endif
; A033486: a(n) = n*(n + 1)*(n + 2)*(n + 3)/2. ; 0,12,60,180,420,840,1512,2520,3960,5940,8580,12012,16380,21840,28560,36720,46512,58140,71820,87780,106260,127512,151800,179400,210600,245700,285012,328860,377580,431520,491040,556512,628320,706860,792540,885780,987012,1096680,1215240,1343160,1480920,1629012,1787940,1958220,2140380,2334960,2542512,2763600,2998800,3248700,3513900,3795012,4092660,4407480,4740120,5091240,5461512,5851620,6262260,6694140,7147980,7624512,8124480,8648640,9197760,9772620,10374012,11002740,11659620,12345480,13061160,13807512,14585400,15395700,16239300,17117100,18030012,18978960,19964880,20988720,22051440,23154012,24297420,25482660,26710740,27982680,29299512,30662280,32072040,33529860,35036820,36594012,38202540,39863520,41578080,43347360,45172512,47054700,48995100,50994900 sub $1,$0 bin $1,4 mul $1,12 mov $0,$1
; A271114: Expansion of (1+x)*(2+x)/(1-x)^2. ; 2,7,13,19,25,31,37,43,49,55,61,67,73,79,85,91,97,103,109,115,121,127,133,139,145,151,157,163,169,175,181,187,193,199,205,211,217,223,229,235,241,247,253,259,265,271,277,283,289,295,301,307,313,319,325,331,337,343,349,355,361,367,373,379,385,391,397,403,409,415,421,427,433,439,445,451,457,463,469,475,481,487,493,499,505,511,517,523,529,535,541,547,553,559,565,571,577,583,589,595 mul $0,6 pow $1,$0 add $1,$0 add $1,1 mov $0,$1
// Ceres Solver - A fast non-linear least squares minimizer // Copyright 2013 Google Inc. All rights reserved. // http://code.google.com/p/ceres-solver/ // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // * Neither the name of Google Inc. nor the names of its contributors may be // used to endorse or promote products derived from this software without // specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // // Author: sameeragarwal@google.com (Sameer Agarwal) // // Template specialization of PartitionedMatrixView. // // ======================================== // THIS FILE IS AUTOGENERATED. DO NOT EDIT. // THIS FILE IS AUTOGENERATED. DO NOT EDIT. // THIS FILE IS AUTOGENERATED. DO NOT EDIT. // THIS FILE IS AUTOGENERATED. DO NOT EDIT. //========================================= // // This file is generated using generate_partitioned_matrix_view_specializations.py. // Editing it manually is not recommended. // This include must come before any #ifndef check on Ceres compile options. #include "ceres/internal/port.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION #include "ceres/partitioned_matrix_view_impl.h" #include "ceres/internal/eigen.h" namespace ceres { namespace internal { template class PartitionedMatrixView<2, 3, 3>; } // namespace internal } // namespace ceres #endif // CERES_RESTRICT_SCHUR_SPECIALIZATION
#ifndef __UTILITY_CHARS_CHAR_TRAITS__ #define __UTILITY_CHARS_CHAR_TRAITS__ /** * \file char_traits.hpp * \author Inochi Amaoto * */ #include<utility/config/utility_config.hpp> #include<utility/sstd/cstring.hpp> #include<utility/sstd/cstdint.hpp> #include<utility/stream/streamoff.hpp> #include<utility/stream/fpos.hpp> namespace utility { namespace charS { template<typename _CharT> struct char_traits { typedef _CharT char_type; typedef int int_type; typedef stream::streamoff off_type; typedef stream::streampos pos_type; typedef sstd::mbstate_t state_type; __UTILITY_CPP14_CONSTEXPR__ static inline void assign(char_type& __c, const char_type& __a) noexcept { __c = __a;} __UTILITY_CPP14_CONSTEXPR__ static inline char_type* assign( char_type* __cptr, size_t __count, char_type __a ) noexcept { char_type* __tmp = __cptr; for(; __count; --__count) { assign(*__tmp++, __a);} return __tmp; } constexpr static inline bool eq(char_type __x, char_type __y) noexcept { return __x == __y;} constexpr static inline bool lt(char_type __x, char_type __y) noexcept { return __x < __y;} static inline char_type* move( char_type* __dest, const char_type* __src, size_t __count ) noexcept { char_type* __tmp = __dest; if(__dest < __src) { for(; __count; --__count, ++__dest, ++__src) { assign(*__dest, *__src);} } else if(__src < __dest) { __dest += __count; __src += __count; for(; __count; --__count) { assign(*--__dest, *--__src);} } return __tmp; } static inline char_type* copy( char_type* __dest, const char_type* __src, size_t __count ) noexcept { char_type* __tmp = __dest; for(;__count; --__count, ++__dest, ++__src) { assign(*__dest, *__src);} return __tmp; } __UTILITY_CPP14_CONSTEXPR__ static inline int compare( const char_type* __comp1, const char_type* __comp2, size_t __count ) noexcept { for(; __count; --__count, ++__comp1, ++__comp2) { if(lt(*__comp1, *__comp2)) { return -1;} if(lt(*__comp2, *__comp1)) { return 1;} } return 0; } __UTILITY_CPP14_CONSTEXPR__ static inline size_t length(const char_type* __str) noexcept { size_t __len = 0; for(; !eq(*__str, char_type(0)); ++__str, ++__len) { } return __len; } __UTILITY_CPP14_CONSTEXPR__ static inline const char_type* find( const char_type* __str, size_t __count, const char_type& __pat ) noexcept { for(; __count; --__count, ++__str) { if(eq(*__str, __pat)) { return __str;} } return nullptr; } constexpr static inline char_type to_char_type(int_type __ch) noexcept { return static_cast<char_type>(__ch);} constexpr static inline int_type to_int_type(char_type __ch) noexcept { return static_cast<int_type>(__ch);} constexpr static inline bool eq_int_type(int_type __ch1, int_type __ch2) noexcept { return __ch1 == __ch2;} constexpr static inline int_type eof() noexcept { return static_cast<int_type>(EOF);} constexpr static inline int_type not_eof(int_type __ch) noexcept { return eq_int_type(__ch, eof()) ? ~eof() : __ch;} }; template<> struct char_traits<char> { typedef char char_type; typedef int int_type; typedef stream::streamoff off_type; typedef stream::streampos pos_type; typedef sstd::mbstate_t state_type; __UTILITY_CPP14_CONSTEXPR__ static inline void assign(char_type& __c, const char_type& __a) noexcept { __c = __a;} __UTILITY_CPP14_CONSTEXPR__ static inline char_type* assign( char_type* __cptr, size_t __count, char_type __a ) noexcept { char_type* __tmp = __cptr; for(; __count; --__count, ++__tmp) { assign(*__tmp, __a);} return __tmp; } constexpr static inline bool eq(char_type __x, char_type __y) noexcept { return __x == __y;} constexpr static inline bool lt(char_type __x, char_type __y) noexcept { return __x < __y;} static inline char_type* move( char_type* __dest, const char_type* __src, size_t __count ) noexcept { char_type* __tmp = __dest; if(__dest < __src) { for(;__count; --__count, ++__dest, ++__src) { assign(*__dest, *__src);} } else if(__src < __dest) { __dest += __count; __src += __count; for(; __count; --__count) { assign(*--__dest, *--__src);} } return __tmp; } static inline char_type* copy( char_type* __dest, const char_type* __src, size_t __count ) noexcept { char_type* __tmp = __dest; for(;__count; --__count, ++__dest, ++__src) { assign(*__dest, *__src);} return __tmp; } __UTILITY_CPP14_CONSTEXPR__ static inline int compare( const char_type* __comp1, const char_type* __comp2, size_t __count ) noexcept { for(; __count; --__count, ++__comp1, ++__comp2) { if(lt(*__comp1, *__comp2)) { return -1;} if(lt(*__comp2, *__comp1)) { return 1;} } return 0; } __UTILITY_CPP14_CONSTEXPR__ static inline size_t length(const char_type* __str) noexcept { size_t __len = 0; for(; !eq(*__str, char_type(0)); ++__str, ++__len) { } return __len; } __UTILITY_CPP14_CONSTEXPR__ static inline const char_type* find( const char_type* __str, size_t __count, const char_type& __pat ) noexcept { for(; __count; --__count, ++__str) { if(eq(*__str, __pat)) { return __str;} } return nullptr; } constexpr static inline char_type to_char_type(int_type __ch) noexcept { return static_cast<char_type>(__ch);} constexpr static inline int_type to_int_type(char_type __ch) noexcept { return static_cast<int_type>(__ch);} constexpr static inline bool eq_int_type(int_type __ch1, int_type __ch2) noexcept { return __ch1 == __ch2;} constexpr static inline int_type eof() noexcept { return static_cast<int_type>(EOF);} constexpr static inline int_type not_eof(int_type __ch) noexcept { return eq_int_type(__ch, eof()) ? ~eof() : __ch;} }; template<> struct char_traits<wchar_t> { typedef wchar_t char_type; typedef sstd::wint_t int_type; typedef stream::streamoff off_type; typedef stream::streampos pos_type; typedef sstd::mbstate_t state_type; __UTILITY_CPP14_CONSTEXPR__ static inline void assign(char_type& __c, const char_type& __a) noexcept { __c = __a;} __UTILITY_CPP14_CONSTEXPR__ static inline char_type* assign( char_type* __cptr, size_t __count, char_type __a ) noexcept { char_type* __tmp = __cptr; for(; __count; --__count, ++__tmp) { assign(*__tmp, __a);} return __tmp; } constexpr static inline bool eq(char_type __x, char_type __y) noexcept { return __x == __y;} constexpr static inline bool lt(char_type __x, char_type __y) noexcept { return __x < __y;} static inline char_type* move( char_type* __dest, const char_type* __src, size_t __count ) noexcept { char_type* __tmp = __dest; if(__dest < __src) { for(;__count; --__count, ++__dest, ++__src) { assign(*__dest, *__src);} } else if(__src < __dest) { __dest += __count; __src += __count; for(; __count; --__count) { assign(*--__dest, *--__src);} } return __tmp; } static inline char_type* copy( char_type* __dest, const char_type* __src, size_t __count ) noexcept { char_type* __tmp = __dest; for(;__count; --__count, ++__dest, ++__src) { assign(*__dest, *__src);} return __tmp; } __UTILITY_CPP14_CONSTEXPR__ static inline int compare( const char_type* __comp1, const char_type* __comp2, size_t __count ) noexcept { for(; __count; --__count, ++__comp1, ++__comp2) { if(lt(*__comp1, *__comp2)) { return -1;} if(lt(*__comp2, *__comp1)) { return 1;} } return 0; } __UTILITY_CPP14_CONSTEXPR__ static inline size_t length(const char_type* __str) noexcept { size_t __len = 0; for(; !eq(*__str, char_type(0)); ++__str, ++__len) { } return __len; } __UTILITY_CPP14_CONSTEXPR__ static inline const char_type* find( const char_type* __str, size_t __count, const char_type& __pat ) noexcept { for(; __count; --__count, ++__str) { if(eq(*__str, __pat)) { return __str;} } return nullptr; } constexpr static inline char_type to_char_type(int_type __ch) noexcept { return static_cast<char_type>(__ch);} constexpr static inline int_type to_int_type(char_type __ch) noexcept { return static_cast<int_type>(__ch);} constexpr static inline bool eq_int_type(int_type __ch1, int_type __ch2) noexcept { return __ch1 == __ch2;} constexpr static inline int_type eof() noexcept { return static_cast<int_type>(WEOF);} constexpr static inline int_type not_eof(int_type __ch) noexcept { return eq_int_type(__ch, eof()) ? ~eof() : __ch;} }; template<> struct char_traits<char16_t> { typedef char16_t char_type; typedef sstd::uint_least16_t int_type; typedef stream::streamoff off_type; typedef stream::u16streampos pos_type; typedef sstd::mbstate_t state_type; __UTILITY_CPP14_CONSTEXPR__ static inline void assign(char_type& __c, const char_type& __a) noexcept { __c = __a;} __UTILITY_CPP14_CONSTEXPR__ static inline char_type* assign( char_type* __cptr, size_t __count, char_type __a ) noexcept { char_type* __tmp = __cptr; for(; __count; --__count, ++__tmp) { assign(*__tmp, __a);} return __tmp; } constexpr static inline bool eq(char_type __x, char_type __y) noexcept { return __x == __y;} constexpr static inline bool lt(char_type __x, char_type __y) noexcept { return __x < __y;} static inline char_type* move( char_type* __dest, const char_type* __src, size_t __count ) noexcept { char_type* __tmp = __dest; if(__dest < __src) { for(;__count; --__count, ++__dest, ++__src) { assign(*__dest, *__src);} } else if(__src < __dest) { __dest += __count; __src += __count; for(; __count; --__count) { assign(*--__dest, *--__src);} } return __tmp; } static inline char_type* copy( char_type* __dest, const char_type* __src, size_t __count ) noexcept { char_type* __tmp = __dest; for(;__count; --__count, ++__dest, ++__src) { assign(*__dest, *__src);} return __tmp; } __UTILITY_CPP14_CONSTEXPR__ static inline int compare( const char_type* __comp1, const char_type* __comp2, size_t __count ) noexcept { for(; __count; --__count, ++__comp1, ++__comp2) { if(lt(*__comp1, *__comp2)) { return -1;} if(lt(*__comp2, *__comp1)) { return 1;} } return 0; } __UTILITY_CPP14_CONSTEXPR__ static inline size_t length(const char_type* __str) noexcept { size_t __len = 0; for(; !eq(*__str, char_type(0)); ++__str, ++__len) { } return __len; } __UTILITY_CPP14_CONSTEXPR__ static inline const char_type* find( const char_type* __str, size_t __count, const char_type& __pat ) noexcept { for(; __count; --__count, ++__str) { if(eq(*__str, __pat)) { return __str;} } return nullptr; } constexpr static inline char_type to_char_type(int_type __ch) noexcept { return static_cast<char_type>(__ch);} constexpr static inline int_type to_int_type(char_type __ch) noexcept { return static_cast<int_type>(__ch);} constexpr static inline bool eq_int_type(int_type __ch1, int_type __ch2) noexcept { return __ch1 == __ch2;} constexpr static inline int_type eof() noexcept { return static_cast<int_type>(WEOF);} constexpr static inline int_type not_eof(int_type __ch) noexcept { return eq_int_type(__ch, eof()) ? static_cast<int_type>(~eof()) : __ch;} }; template<> struct char_traits<char32_t> { typedef char32_t char_type; typedef sstd::uint_least32_t int_type; typedef stream::streamoff off_type; typedef stream::u32streampos pos_type; typedef sstd::mbstate_t state_type; __UTILITY_CPP14_CONSTEXPR__ static inline void assign(char_type& __c, const char_type& __a) noexcept { __c = __a;} __UTILITY_CPP14_CONSTEXPR__ static inline char_type* assign( char_type* __cptr, size_t __count, char_type __a ) noexcept { char_type* __tmp = __cptr; for(; __count; --__count, ++__tmp) { assign(*__tmp, __a);} return __tmp; } constexpr static inline bool eq(char_type __x, char_type __y) noexcept { return __x == __y;} constexpr static inline bool lt(char_type __x, char_type __y) noexcept { return __x < __y;} static inline char_type* move( char_type* __dest, const char_type* __src, size_t __count ) noexcept { char_type* __tmp = __dest; if(__dest < __src) { for(;__count; --__count, ++__dest, ++__src) { assign(*__dest, *__src);} } else if(__src < __dest) { __dest += __count; __src += __count; for(; __count; --__count) { assign(*--__dest, *--__src);} } return __tmp; } static inline char_type* copy( char_type* __dest, const char_type* __src, size_t __count ) noexcept { char_type* __tmp = __dest; for(;__count; --__count, ++__dest, ++__src) { assign(*__dest, *__src);} return __tmp; } __UTILITY_CPP14_CONSTEXPR__ static inline int compare( const char_type* __comp1, const char_type* __comp2, size_t __count ) noexcept { for(; __count; --__count, ++__comp1, ++__comp2) { if(lt(*__comp1, *__comp2)) { return -1;} if(lt(*__comp2, *__comp1)) { return 1;} } return 0; } __UTILITY_CPP14_CONSTEXPR__ static inline size_t length(const char_type* __str) noexcept { size_t __len = 0; for(; !eq(*__str, char_type(0)); ++__str, ++__len) { } return __len; } __UTILITY_CPP14_CONSTEXPR__ static inline const char_type* find( const char_type* __str, size_t __count, const char_type& __pat ) noexcept { for(; __count; --__count, ++__str) { if(eq(*__str, __pat)) { return __str;} } return nullptr; } constexpr static inline char_type to_char_type(int_type __ch) noexcept { return static_cast<char_type>(__ch);} constexpr static inline int_type to_int_type(char_type __ch) noexcept { return static_cast<int_type>(__ch);} constexpr static inline bool eq_int_type(int_type __ch1, int_type __ch2) noexcept { return __ch1 == __ch2;} constexpr static inline int_type eof() noexcept { return static_cast<int_type>(WEOF);} constexpr static inline int_type not_eof(int_type __ch) noexcept { return eq_int_type(__ch, eof()) ? ~eof() : __ch;} }; } } #endif // ! __UTILITY_CHARS_CHAR_TRAITS__
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r15 push %r8 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_D_ht+0x17f98, %r8 nop nop nop and %r11, %r11 movups (%r8), %xmm5 vpextrq $1, %xmm5, %rbp nop nop cmp $33929, %rbx lea addresses_UC_ht+0x1d1f8, %r15 nop nop xor %rsi, %rsi mov (%r15), %bp nop dec %r15 lea addresses_normal_ht+0x1ef18, %r8 nop nop nop nop nop add $62501, %rcx movw $0x6162, (%r8) dec %rbp lea addresses_WT_ht+0x7018, %rsi lea addresses_D_ht+0x18c78, %rdi clflush (%rdi) nop nop nop nop add $53191, %rbx mov $19, %rcx rep movsq add %rbx, %rbx lea addresses_normal_ht+0x5ae8, %rcx nop nop nop nop nop add %r8, %r8 mov (%rcx), %r15 nop nop nop nop nop and $1444, %r15 lea addresses_normal_ht+0x418, %r11 clflush (%r11) nop nop nop xor $35075, %r15 mov (%r11), %ebx nop nop nop nop and $43409, %rcx lea addresses_normal_ht+0x13fd0, %r8 nop nop nop cmp $11871, %rbp mov $0x6162636465666768, %rdi movq %rdi, %xmm4 movups %xmm4, (%r8) nop and $32966, %rdi lea addresses_A_ht+0xdcb8, %rdi sub %rsi, %rsi and $0xffffffffffffffc0, %rdi vmovaps (%rdi), %ymm2 vextracti128 $0, %ymm2, %xmm2 vpextrq $1, %xmm2, %rcx nop and $566, %rdi pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r8 pop %r15 pop %r11 ret .global s_faulty_load s_faulty_load: push %r12 push %r15 push %r8 push %r9 push %rax push %rdx push %rsi // Store lea addresses_US+0x13e18, %rax nop sub $13936, %r15 mov $0x5152535455565758, %rsi movq %rsi, %xmm4 vmovups %ymm4, (%rax) nop nop dec %r12 // Store lea addresses_PSE+0xafc0, %rdx nop add %r8, %r8 mov $0x5152535455565758, %r15 movq %r15, %xmm2 movntdq %xmm2, (%rdx) nop sub $29380, %r12 // Load lea addresses_A+0xe898, %rdx clflush (%rdx) nop nop nop nop dec %rax mov (%rdx), %r9 nop nop nop nop nop cmp %r12, %r12 // Faulty Load lea addresses_RW+0x12418, %r9 nop nop nop dec %rdx movups (%r9), %xmm6 vpextrq $0, %xmm6, %r8 lea oracles, %rsi and $0xff, %r8 shlq $12, %r8 mov (%rsi,%r8,1), %r8 pop %rsi pop %rdx pop %rax pop %r9 pop %r8 pop %r15 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_RW', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_US', 'same': False, 'AVXalign': False, 'congruent': 9}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': True, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_A', 'same': False, 'AVXalign': False, 'congruent': 3}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_RW', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_D_ht', 'same': True, 'AVXalign': False, 'congruent': 5}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 4}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 7}} {'OP': 'REPM', 'src': {'same': True, 'type': 'addresses_WT_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 1}} {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 4}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 10}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 2}} {'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': True, 'congruent': 3}} {'32': 21829} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 */
//===--- CSDiag.cpp - Constraint Diagnostics ------------------------------===// // // This source file is part of the Swift.org open source project // // Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// // // This file implements diagnostics for the type checker. // //===----------------------------------------------------------------------===// #include "CSDiag.h" #include "CSDiagnostics.h" #include "CalleeCandidateInfo.h" #include "ConstraintSystem.h" #include "MiscDiagnostics.h" #include "TypeCheckAvailability.h" #include "TypoCorrection.h" #include "swift/AST/ASTWalker.h" #include "swift/AST/DiagnosticEngine.h" #include "swift/AST/GenericEnvironment.h" #include "swift/AST/Initializer.h" #include "swift/AST/ParameterList.h" #include "swift/AST/ProtocolConformance.h" #include "swift/AST/TypeMatcher.h" #include "swift/AST/TypeWalker.h" #include "swift/Basic/Defer.h" #include "swift/Basic/StringExtras.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SetVector.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/SaveAndRestore.h" using namespace swift; using namespace constraints; namespace swift { std::string getTypeListString(Type type) { std::string result; // Always make sure to have at least one set of parens bool forceParens = !type->is<TupleType>() && !type->hasParenSugar(); if (forceParens) result.push_back('('); llvm::raw_string_ostream OS(result); type->print(OS); OS.flush(); if (forceParens) result.push_back(')'); return result; } Type replaceTypeParametersWithUnresolved(Type ty) { if (!ty) return ty; if (!ty->hasTypeParameter() && !ty->hasArchetype()) return ty; auto &ctx = ty->getASTContext(); return ty.transform([&](Type type) -> Type { if (type->is<ArchetypeType>() || type->isTypeParameter()) return ctx.TheUnresolvedType; return type; }); } Type replaceTypeVariablesWithUnresolved(Type ty) { if (!ty) return ty; if (!ty->hasTypeVariable()) return ty; auto &ctx = ty->getASTContext(); return ty.transform([&](Type type) -> Type { if (type->isTypeVariableOrMember()) return ctx.TheUnresolvedType; return type; }); } }; static bool isUnresolvedOrTypeVarType(Type ty) { return ty->isTypeVariableOrMember() || ty->is<UnresolvedType>(); } /// Given a subpath of an old locator, compute its summary flags. static unsigned recomputeSummaryFlags(ConstraintLocator *oldLocator, ArrayRef<LocatorPathElt> path) { if (oldLocator->getSummaryFlags() != 0) return ConstraintLocator::getSummaryFlagsForPath(path); return 0; } ConstraintLocator * constraints::simplifyLocator(ConstraintSystem &cs, ConstraintLocator *locator, SourceRange &range, ConstraintLocator **targetLocator) { // Clear out the target locator result. if (targetLocator) *targetLocator = nullptr; // The path to be tacked on to the target locator to identify the specific // target. Expr *targetAnchor; SmallVector<LocatorPathElt, 4> targetPath; auto path = locator->getPath(); auto anchor = locator->getAnchor(); simplifyLocator(anchor, path, targetAnchor, targetPath, range); // If we have a target anchor, build and simplify the target locator. if (targetLocator && targetAnchor) { SourceRange targetRange; unsigned targetFlags = recomputeSummaryFlags(locator, targetPath); auto loc = cs.getConstraintLocator(targetAnchor, targetPath, targetFlags); *targetLocator = simplifyLocator(cs, loc, targetRange); } // If we didn't simplify anything, just return the input. if (anchor == locator->getAnchor() && path.size() == locator->getPath().size()) { return locator; } // Recompute the summary flags if we had any to begin with. This is // necessary because we might remove e.g. tuple elements from the path. unsigned summaryFlags = recomputeSummaryFlags(locator, path); return cs.getConstraintLocator(anchor, path, summaryFlags); } void constraints::simplifyLocator(Expr *&anchor, ArrayRef<LocatorPathElt> &path, Expr *&targetAnchor, SmallVectorImpl<LocatorPathElt> &targetPath, SourceRange &range) { range = SourceRange(); targetAnchor = nullptr; while (!path.empty()) { switch (path[0].getKind()) { case ConstraintLocator::ApplyArgument: { // Extract application argument. if (auto applyExpr = dyn_cast<ApplyExpr>(anchor)) { // The target anchor is the function being called. targetAnchor = applyExpr->getFn(); targetPath.push_back(path[0]); anchor = applyExpr->getArg(); path = path.slice(1); continue; } if (auto objectLiteralExpr = dyn_cast<ObjectLiteralExpr>(anchor)) { targetAnchor = nullptr; targetPath.clear(); anchor = objectLiteralExpr->getArg(); path = path.slice(1); continue; } // SWIFT_ENABLE_TENSORFLOW if (auto *poundAssertExpr = dyn_cast<PoundAssertExpr>(anchor)) { targetAnchor = nullptr; targetPath.clear(); anchor = poundAssertExpr->getCondition(); path = path.slice(1); continue; } if (auto *UME = dyn_cast<UnresolvedMemberExpr>(anchor)) { // The target anchor is the method being called, // no additional information could be retrieved // about this call. targetAnchor = nullptr; targetPath.clear(); anchor = UME->getArgument(); path = path.slice(1); continue; } break; } case ConstraintLocator::ApplyFunction: // Extract application function. if (auto applyExpr = dyn_cast<ApplyExpr>(anchor)) { // No additional target locator information. targetAnchor = nullptr; targetPath.clear(); anchor = applyExpr->getFn(); path = path.slice(1); continue; } // The unresolved member itself is the function. if (auto unresolvedMember = dyn_cast<UnresolvedMemberExpr>(anchor)) { if (unresolvedMember->getArgument()) { // No additional target locator information. targetAnchor = nullptr; targetPath.clear(); anchor = unresolvedMember; path = path.slice(1); continue; } } break; case ConstraintLocator::AutoclosureResult: case ConstraintLocator::LValueConversion: case ConstraintLocator::RValueAdjustment: case ConstraintLocator::UnresolvedMember: // Arguments in autoclosure positions, lvalue and rvalue adjustments, and // scalar-to-tuple conversions, and unresolved members are // implicit. path = path.slice(1); continue; case ConstraintLocator::NamedTupleElement: case ConstraintLocator::TupleElement: // Extract tuple element. if (auto tupleExpr = dyn_cast<TupleExpr>(anchor)) { unsigned index = path[0].getValue(); if (index < tupleExpr->getNumElements()) { // Append this extraction to the target locator path. if (targetAnchor) { targetPath.push_back(path[0]); } anchor = tupleExpr->getElement(index); path = path.slice(1); continue; } } break; case ConstraintLocator::ApplyArgToParam: // Extract tuple element. if (auto tupleExpr = dyn_cast<TupleExpr>(anchor)) { unsigned index = path[0].getValue(); if (index < tupleExpr->getNumElements()) { // Append this extraction to the target locator path. if (targetAnchor) { targetPath.push_back(path[0]); } anchor = tupleExpr->getElement(index); path = path.slice(1); continue; } } // Extract subexpression in parentheses. if (auto parenExpr = dyn_cast<ParenExpr>(anchor)) { assert(path[0].getValue() == 0); // Append this extraction to the target locator path. if (targetAnchor) { targetPath.push_back(path[0]); } anchor = parenExpr->getSubExpr(); path = path.slice(1); continue; } break; case ConstraintLocator::ConstructorMember: if (auto typeExpr = dyn_cast<TypeExpr>(anchor)) { // This is really an implicit 'init' MemberRef, so point at the base, // i.e. the TypeExpr. targetAnchor = nullptr; targetPath.clear(); range = SourceRange(); anchor = typeExpr; path = path.slice(1); continue; } LLVM_FALLTHROUGH; case ConstraintLocator::Member: case ConstraintLocator::MemberRefBase: if (auto UDE = dyn_cast<UnresolvedDotExpr>(anchor)) { // No additional target locator information. targetAnchor = nullptr; targetPath.clear(); range = UDE->getNameLoc().getSourceRange(); anchor = UDE->getBase(); path = path.slice(1); continue; } break; case ConstraintLocator::SubscriptMember: if (isa<SubscriptExpr>(anchor)) { targetAnchor = nullptr; targetPath.clear(); path = path.slice(1); continue; } break; case ConstraintLocator::ClosureResult: if (auto CE = dyn_cast<ClosureExpr>(anchor)) { if (CE->hasSingleExpressionBody()) { targetAnchor = nullptr; targetPath.clear(); anchor = CE->getSingleExpressionBody(); path = path.slice(1); continue; } } break; case ConstraintLocator::ContextualType: // This was just for identifying purposes, strip it off. path = path.slice(1); continue; default: // FIXME: Lots of other cases to handle. break; } // If we get here, we couldn't simplify the path further. break; } } /// Flags that can be used to control name lookup. enum TCCFlags { /// Allow the result of the subexpression to be an lvalue. If this is not /// specified, any lvalue will be forced to be loaded into an rvalue. TCC_AllowLValue = 0x01, /// Re-type-check the given subexpression even if the expression has already /// been checked already. The client is asserting that infinite recursion is /// not possible because it has relaxed a constraint on the system. TCC_ForceRecheck = 0x02, /// tell typeCheckExpression that it is ok to produce an ambiguous result, /// it can just fill in holes with UnresolvedType and we'll deal with it. TCC_AllowUnresolvedTypeVariables = 0x04 }; using TCCOptions = OptionSet<TCCFlags>; inline TCCOptions operator|(TCCFlags flag1, TCCFlags flag2) { return TCCOptions(flag1) | flag2; } namespace { /// If a constraint system fails to converge on a solution for a given /// expression, this class can produce a reasonable diagnostic for the failure /// by analyzing the remnants of the failed constraint system. (Specifically, /// left-over inactive, active and failed constraints.) /// This class does not tune its diagnostics for a specific expression kind, /// for that, you'll want to use an instance of the FailureDiagnosis class. class FailureDiagnosis :public ASTVisitor<FailureDiagnosis, /*exprresult*/bool>{ friend class ASTVisitor<FailureDiagnosis, /*exprresult*/bool>; Expr *expr = nullptr; ConstraintSystem &CS; public: FailureDiagnosis(Expr *expr, ConstraintSystem &cs) : expr(expr), CS(cs) { assert(expr); } template<typename ...ArgTypes> InFlightDiagnostic diagnose(ArgTypes &&...Args) { return CS.TC.diagnose(std::forward<ArgTypes>(Args)...); } /// Attempt to diagnose a failure without taking into account the specific /// kind of expression that could not be type checked. bool diagnoseConstraintFailure(); /// Unless we've already done this, retypecheck the specified child of the /// current expression on its own, without including any contextual /// constraints or the parent expr nodes. This is more likely to succeed than /// type checking the original expression. /// /// This mention may only be used on immediate children of the current expr /// node, because ClosureExpr parameters need to be treated specially. /// /// This can return a new expression (for e.g. when a UnresolvedDeclRef gets /// resolved) and returns null when the subexpression fails to typecheck. /// Expr *typeCheckChildIndependently( Expr *subExpr, Type convertType = Type(), ContextualTypePurpose convertTypePurpose = CTP_Unused, TCCOptions options = TCCOptions(), ExprTypeCheckListener *listener = nullptr, bool allowFreeTypeVariables = true); Expr *typeCheckChildIndependently(Expr *subExpr, TCCOptions options, bool allowFreeTypeVariables = true) { return typeCheckChildIndependently(subExpr, Type(), CTP_Unused, options, nullptr, allowFreeTypeVariables); } Type getTypeOfTypeCheckedChildIndependently(Expr *subExpr, TCCOptions options = TCCOptions()) { auto e = typeCheckChildIndependently(subExpr, options); return e ? CS.getType(e) : Type(); } /// This is the same as typeCheckChildIndependently, but works on an arbitrary /// subexpression of the current node because it handles ClosureExpr parents /// of the specified node. Expr *typeCheckArbitrarySubExprIndependently(Expr *subExpr, TCCOptions options = TCCOptions()); /// Special magic to handle inout exprs and tuples in argument lists. Expr *typeCheckArgumentChildIndependently(Expr *argExpr, Type argType, const CalleeCandidateInfo &candidates, TCCOptions options = TCCOptions()); /// Diagnose common failures due to applications of an argument list to an /// ApplyExpr or SubscriptExpr. bool diagnoseParameterErrors(CalleeCandidateInfo &CCI, Expr *fnExpr, Expr *argExpr, ArrayRef<Identifier> argLabels); /// Attempt to diagnose a specific failure from the info we've collected from /// the failed constraint system. bool diagnoseExprFailure(); /// Emit an ambiguity diagnostic about the specified expression. void diagnoseAmbiguity(Expr *E); /// Attempt to produce a diagnostic for a mismatch between an expression's /// type and its assumed contextual type. bool diagnoseContextualConversionError(Expr *expr, Type contextualType, ContextualTypePurpose CTP, Type suggestedType = Type()); /// For an expression being type checked with a CTP_CalleeResult contextual /// type, try to diagnose a problem. bool diagnoseCalleeResultContextualConversionError(); /// Attempt to produce a diagnostic for a mismatch between a call's /// type and its assumed contextual type. bool diagnoseCallContextualConversionErrors(ApplyExpr *callEpxr, Type contextualType, ContextualTypePurpose CTP); private: /// Validate potential contextual type for type-checking one of the /// sub-expressions, usually correct/valid types are the ones which /// either don't have type variables or are not generic, because /// generic types with left-over type variables or unresolved types /// degrade quality of diagnostics if allowed to be used as contextual. /// /// \param contextualType The candidate contextual type. /// \param CTP The contextual purpose attached to the given candidate. /// /// \returns Pair of validated type and it's purpose, potentially nullified /// if it wasn't an appropriate type to be used. std::pair<Type, ContextualTypePurpose> validateContextualType(Type contextualType, ContextualTypePurpose CTP); /// Check the specified closure to see if it is a multi-statement closure with /// an uninferred type. If so, diagnose the problem with an error and return /// true. bool diagnoseAmbiguousMultiStatementClosure(ClosureExpr *closure); /// Check the associated constraint system to see if it has any opened generic /// parameters that were not bound to a fixed type. If so, diagnose the /// problem with an error and return true. bool diagnoseAmbiguousGenericParameters(); /// Emit an error message about an unbound generic parameter, and emit notes /// referring to the target of a diagnostic, e.g., the function or parameter /// being used. void diagnoseAmbiguousGenericParameter(GenericTypeParamType *paramTy, Expr *anchor); /// Produce a diagnostic for a general member-lookup failure (irrespective of /// the exact expression kind). bool diagnoseGeneralMemberFailure(Constraint *constraint); /// Diagnose the lookup of a static member or enum element as instance member. void diagnoseTypeMemberOnInstanceLookup(Type baseObjTy, Expr *baseExpr, DeclName memberName, DeclNameLoc nameLoc, ValueDecl *member, SourceLoc loc); /// Given a result of name lookup that had no viable results, diagnose the /// unviable ones. void diagnoseUnviableLookupResults(MemberLookupResult &lookupResults, Type baseObjTy, Expr *baseExpr, DeclName memberName, DeclNameLoc nameLoc, SourceLoc loc); /// Produce a diagnostic for a general overload resolution failure /// (irrespective of the exact expression kind). bool diagnoseGeneralOverloadFailure(Constraint *constraint); /// Produce a diagnostic for a general conversion failure (irrespective of the /// exact expression kind). bool diagnoseGeneralConversionFailure(Constraint *constraint); /// Produce a specialized diagnostic if this is an invalid conversion to Bool. bool diagnoseConversionToBool(Expr *expr, Type exprType); /// Produce a diagnostic for binary comparisons of the nil literal /// to other values. bool diagnoseNilLiteralComparison(Expr *lhsExpr, Expr *rhsExpr, CalleeCandidateInfo &calleeInfo, SourceLoc applyLoc); /// Produce diagnostic for failures related to attributes associated with /// candidate functions/methods e.g. mutability. bool diagnoseMethodAttributeFailures(ApplyExpr *expr, ArrayRef<Identifier> argLabels, bool hasTrailingClosure, CalleeCandidateInfo &candidates); /// Produce diagnostic for failures related to unfulfilled requirements /// of the generic parameters used as arguments. bool diagnoseArgumentGenericRequirements(TypeChecker &TC, Expr *callExpr, Expr *fnExpr, Expr *argExpr, CalleeCandidateInfo &candidates, ArrayRef<Identifier> argLabels); bool diagnoseMemberFailures( Expr *E, Expr *baseEpxr, ConstraintKind lookupKind, DeclName memberName, FunctionRefKind funcRefKind, ConstraintLocator *locator, Optional<std::function<bool(ArrayRef<OverloadChoice>)>> callback = None, bool includeInaccessibleMembers = true); bool diagnoseTrailingClosureErrors(ApplyExpr *expr); bool diagnoseClosureExpr(ClosureExpr *closureExpr, Type contextualType, llvm::function_ref<bool(Type, Type)> resultTypeProcessor); bool diagnoseSubscriptErrors(SubscriptExpr *SE, bool performingSet); // SWIFT_ENABLE_TENSORFLOW bool diagnoseReverseAutoDiffExpr(ReverseAutoDiffExpr *GE); /// Diagnose the usage of 'subscript' instead of the operator when calling /// a subscript and offer a fixit if the inputs are compatible. bool diagnoseSubscriptMisuse(ApplyExpr *callExpr); bool visitExpr(Expr *E); bool visitIdentityExpr(IdentityExpr *E); bool visitTryExpr(TryExpr *E); bool visitTupleExpr(TupleExpr *E); bool visitUnresolvedMemberExpr(UnresolvedMemberExpr *E); bool visitUnresolvedDotExpr(UnresolvedDotExpr *UDE); bool visitArrayExpr(ArrayExpr *E); bool visitDictionaryExpr(DictionaryExpr *E); bool visitObjectLiteralExpr(ObjectLiteralExpr *E); bool visitForceValueExpr(ForceValueExpr *FVE); bool visitBindOptionalExpr(BindOptionalExpr *BOE); bool visitSubscriptExpr(SubscriptExpr *SE); bool visitApplyExpr(ApplyExpr *AE); bool visitAssignExpr(AssignExpr *AE); bool visitInOutExpr(InOutExpr *IOE); bool visitCoerceExpr(CoerceExpr *CE); bool visitIfExpr(IfExpr *IE); bool visitRebindSelfInConstructorExpr(RebindSelfInConstructorExpr *E); bool visitCaptureListExpr(CaptureListExpr *CLE); bool visitClosureExpr(ClosureExpr *CE); bool visitKeyPathExpr(KeyPathExpr *KPE); // SWIFT_ENABLE_TENSORFLOW bool visitReverseAutoDiffExpr(ReverseAutoDiffExpr *RADE); bool visitPoundAssertExpr(PoundAssertExpr *PAE); }; } // end anonymous namespace static bool isMemberConstraint(Constraint *C) { return C->getClassification() == ConstraintClassification::Member; } static bool isOverloadConstraint(Constraint *C) { if (C->getKind() == ConstraintKind::BindOverload) return true; if (C->getKind() != ConstraintKind::Disjunction) return false; return C->getNestedConstraints().front()->getKind() == ConstraintKind::BindOverload; } /// Return true if this constraint is a conversion or requirement between two /// types. static bool isConversionConstraint(const Constraint *C) { return C->getClassification() == ConstraintClassification::Relational; } /// Attempt to diagnose a failure without taking into account the specific /// kind of expression that could not be type checked. bool FailureDiagnosis::diagnoseConstraintFailure() { // This is the priority order in which we handle constraints. Things earlier // in the list are considered to have higher specificity (and thus, higher // priority) than things lower in the list. enum ConstraintRanking { CR_MemberConstraint, CR_ConversionConstraint, CR_OverloadConstraint, CR_OtherConstraint }; // Start out by classifying all the constraints. using RCElt = std::pair<Constraint *, ConstraintRanking>; std::vector<RCElt> rankedConstraints; // This is a predicate that classifies constraints according to our // priorities. std::function<void (Constraint*)> classifyConstraint = [&](Constraint *C) { if (isMemberConstraint(C)) return rankedConstraints.push_back({C, CR_MemberConstraint}); if (isOverloadConstraint(C)) return rankedConstraints.push_back({C, CR_OverloadConstraint}); if (isConversionConstraint(C)) return rankedConstraints.push_back({C, CR_ConversionConstraint}); // We occasionally end up with disjunction constraints containing an // original constraint along with one considered with a fix. If we find // this situation, add the original one to our list for diagnosis. if (C->getKind() == ConstraintKind::Disjunction) { Constraint *Orig = nullptr; bool AllOthersHaveFixes = true; for (auto DC : C->getNestedConstraints()) { // If this is a constraint inside of the disjunction with a fix, ignore // it. if (DC->getFix()) continue; // If we already found a candidate without a fix, we can't do this. if (Orig) { AllOthersHaveFixes = false; break; } // Remember this as the exemplar to use. Orig = DC; } if (Orig && AllOthersHaveFixes) return classifyConstraint(Orig); // If we got all the way down to a truly ambiguous disjunction constraint // with a conversion in it, the problem could be that none of the options // in the disjunction worked. // // We don't have a lot of great options here, so (if all else fails), // we'll attempt to diagnose the issue as though the first option was the // problem. rankedConstraints.push_back({ C->getNestedConstraints()[0], CR_OtherConstraint }); return; } return rankedConstraints.push_back({C, CR_OtherConstraint}); }; // Look at the failed constraint and the general constraint list. Processing // the failed constraint first slightly biases it in the ranking ahead of // other failed constraints at the same level. if (CS.failedConstraint) classifyConstraint(CS.failedConstraint); for (auto &C : CS.getConstraints()) classifyConstraint(&C); // Okay, now that we've classified all the constraints, sort them by their // priority and privilege the favored constraints. std::stable_sort(rankedConstraints.begin(), rankedConstraints.end(), [&] (RCElt LHS, RCElt RHS) { // Rank things by their kind as the highest priority. if (LHS.second < RHS.second) return true; if (LHS.second > RHS.second) return false; // Next priority is favored constraints. if (LHS.first->isFavored() != RHS.first->isFavored()) return LHS.first->isFavored(); return false; }); // Now that we have a sorted precedence of constraints to diagnose, charge // through them. for (auto elt : rankedConstraints) { auto C = elt.first; if (isMemberConstraint(C) && diagnoseGeneralMemberFailure(C)) return true; if (isConversionConstraint(C) && diagnoseGeneralConversionFailure(C)) return true; if (isOverloadConstraint(C) && diagnoseGeneralOverloadFailure(C)) return true; // TODO: There can be constraints that aren't handled here! When this // happens, we end up diagnosing them as ambiguities that don't make sense. // This isn't as bad as it seems though, because most of these will be // diagnosed by expr diagnostics. } // Otherwise, all the constraints look ok, diagnose this as an ambiguous // expression. return false; } bool FailureDiagnosis::diagnoseGeneralMemberFailure(Constraint *constraint) { assert(isMemberConstraint(constraint)); // Get the referenced base expression from the failed constraint, along with // the SourceRange for the member ref. In "x.y", this returns the expr for x // and the source range for y. auto anchor = expr; SourceRange memberRange = anchor->getSourceRange(); auto locator = constraint->getLocator(); if (locator) { locator = simplifyLocator(CS, locator, memberRange); if (locator->getAnchor()) anchor = locator->getAnchor(); } // Check to see if this is a locator referring to something we cannot or do // here: in this case, we ignore paths that end on archetypes witnesses, or // associated types of the expression. if (locator && !locator->getPath().empty()) { // TODO: This should only ignore *unresolved* archetypes. For resolved // archetypes return false; } return diagnoseMemberFailures(expr, anchor, constraint->getKind(), constraint->getMember(), constraint->getFunctionRefKind(), locator); } void FailureDiagnosis:: diagnoseTypeMemberOnInstanceLookup(Type baseObjTy, Expr *baseExpr, DeclName memberName, DeclNameLoc nameLoc, ValueDecl *member, SourceLoc loc) { SourceRange baseRange = baseExpr ? baseExpr->getSourceRange() : SourceRange(); Optional<InFlightDiagnostic> Diag; // If the base of the lookup is a protocol metatype, suggest // to replace the metatype with 'Self' // error saying the lookup cannot be on a protocol metatype if (auto metatypeTy = baseObjTy->getAs<MetatypeType>()) { auto instanceTy = metatypeTy->getInstanceType(); // This will only happen if we have an unresolved dot expression // (.foo) where foo is a protocol member and the contextual type is // an optional protocol metatype. if (auto objectTy = instanceTy->getOptionalObjectType()) { instanceTy = objectTy; baseObjTy = MetatypeType::get(objectTy); } assert(instanceTy->isExistentialType()); // Give a customized message if we're accessing a member type // of a protocol -- otherwise a diagnostic talking about // static members doesn't make a whole lot of sense if (auto TAD = dyn_cast<TypeAliasDecl>(member)) { Diag.emplace(diagnose(loc, diag::typealias_outside_of_protocol, TAD->getName())); } else if (auto ATD = dyn_cast<AssociatedTypeDecl>(member)) { Diag.emplace(diagnose(loc, diag::assoc_type_outside_of_protocol, ATD->getName())); } else if (isa<ConstructorDecl>(member)) { Diag.emplace(diagnose(loc, diag::construct_protocol_by_name, instanceTy)); } else { Diag.emplace(diagnose(loc, diag::could_not_use_type_member_on_protocol_metatype, baseObjTy, memberName)); } Diag->highlight(baseRange).highlight(nameLoc.getSourceRange()); // See through function decl context if (auto parent = CS.DC->getInnermostTypeContext()) { // If we are in a protocol extension of 'Proto' and we see // 'Proto.static', suggest 'Self.static' if (auto extensionContext = parent->getExtendedProtocolDecl()) { if (extensionContext->getDeclaredType()->isEqual(instanceTy)) { Diag->fixItReplace(baseRange, "Self"); } } } return; } if (isa<EnumElementDecl>(member)) Diag.emplace(diagnose(loc, diag::could_not_use_enum_element_on_instance, memberName)); else Diag.emplace(diagnose(loc, diag::could_not_use_type_member_on_instance, baseObjTy, memberName)); Diag->highlight(nameLoc.getSourceRange()); // No fix-it if the lookup was qualified if (baseExpr && !baseExpr->isImplicit()) return; // Determine the contextual type of the expression Type contextualType; for (auto iterateCS = &CS; contextualType.isNull() && iterateCS; iterateCS = iterateCS->baseCS) { contextualType = iterateCS->getContextualType(); } // Try to provide a fix-it that only contains a '.' if (contextualType) { if (baseObjTy->isEqual(contextualType)) { Diag->fixItInsert(loc, "."); return; } } // Check if the expression is the matching operator ~=, most often used in // case statements. If so, try to provide a single dot fix-it const Expr *contextualTypeNode = nullptr; ConstraintSystem *lastCS = nullptr; for (auto iterateCS = &CS; iterateCS; iterateCS = iterateCS->baseCS) { lastCS = iterateCS; contextualTypeNode = iterateCS->getContextualTypeNode(); } // The '~=' operator is an overloaded decl ref inside a binaryExpr if (auto binaryExpr = dyn_cast<BinaryExpr>(contextualTypeNode)) { if (auto overloadedFn = dyn_cast<OverloadedDeclRefExpr>(binaryExpr->getFn())) { if (!overloadedFn->getDecls().empty()) { // Fetch any declaration to check if the name is '~=' ValueDecl *decl0 = overloadedFn->getDecls()[0]; if (decl0->getBaseName() == decl0->getASTContext().Id_MatchOperator) { assert(binaryExpr->getArg()->getElements().size() == 2); // If the rhs of '~=' is the enum type, a single dot suffixes // since the type can be inferred Type secondArgType = lastCS->getType(binaryExpr->getArg()->getElement(1)); if (secondArgType->isEqual(baseObjTy)) { Diag->fixItInsert(loc, "."); return; } } } } } // Fall back to a fix-it with a full type qualifier auto nominal = member->getDeclContext()->getSelfNominalTypeDecl(); SmallString<32> typeName; llvm::raw_svector_ostream typeNameStream(typeName); typeNameStream << nominal->getSelfInterfaceType() << "."; Diag->fixItInsert(loc, typeNameStream.str()); return; } /// When a user refers a enum case with a wrong member name, we try to find a enum /// element whose name differs from the wrong name only in convention; meaning their /// lower case counterparts are identical. /// - DeclName is valid when such a correct case is found; invalid otherwise. static DeclName findCorrectEnumCaseName(Type Ty, TypoCorrectionResults &corrections, DeclName memberName) { if (memberName.isSpecial() || !memberName.isSimpleName()) return DeclName(); if (!Ty->is<EnumType>() && !Ty->is<BoundGenericEnumType>()) return DeclName(); auto candidate = corrections.getUniqueCandidateMatching([&](ValueDecl *candidate) { return (isa<EnumElementDecl>(candidate) && candidate->getFullName().getBaseIdentifier().str() .equals_lower(memberName.getBaseIdentifier().str())); }); return (candidate ? candidate->getFullName() : DeclName()); } /// Given a result of name lookup that had no viable results, diagnose the /// unviable ones. void FailureDiagnosis:: diagnoseUnviableLookupResults(MemberLookupResult &result, Type baseObjTy, Expr *baseExpr, DeclName memberName, DeclNameLoc nameLoc, SourceLoc loc) { SourceRange baseRange = baseExpr ? baseExpr->getSourceRange() : SourceRange(); // If we found no results at all, mention that fact. if (result.UnviableCandidates.empty()) { TypoCorrectionResults corrections(CS.TC, memberName, nameLoc); auto tryTypoCorrection = [&] { CS.TC.performTypoCorrection(CS.DC, DeclRefKind::Ordinary, baseObjTy, defaultMemberLookupOptions, corrections); }; // TODO: This should handle tuple member lookups, like x.1231 as well. if (memberName.getBaseName().getKind() == DeclBaseName::Kind::Subscript) { diagnose(loc, diag::could_not_find_value_subscript, baseObjTy) .highlight(baseRange); } else if (memberName.getBaseName() == "deinit") { // Specialised diagnostic if trying to access deinitialisers diagnose(loc, diag::destructor_not_accessible).highlight(baseRange); } else if (auto metatypeTy = baseObjTy->getAs<MetatypeType>()) { auto instanceTy = metatypeTy->getInstanceType(); tryTypoCorrection(); if (DeclName rightName = findCorrectEnumCaseName(instanceTy, corrections, memberName)) { diagnose(loc, diag::could_not_find_enum_case, instanceTy, memberName, rightName) .fixItReplace(nameLoc.getBaseNameLoc(), rightName.getBaseIdentifier().str()); return; } if (auto correction = corrections.claimUniqueCorrection()) { auto diagnostic = diagnose(loc, diag::could_not_find_type_member_corrected, instanceTy, memberName, correction->CorrectedName); diagnostic.highlight(baseRange).highlight(nameLoc.getSourceRange()); correction->addFixits(diagnostic); } else { diagnose(loc, diag::could_not_find_type_member, instanceTy, memberName) .highlight(baseRange).highlight(nameLoc.getSourceRange()); } } else if (auto moduleTy = baseObjTy->getAs<ModuleType>()) { diagnose(baseExpr->getLoc(), diag::no_member_of_module, moduleTy->getModule()->getName(), memberName) .highlight(baseRange) .highlight(nameLoc.getSourceRange()); return; } else { auto emitBasicError = [&] { diagnose(loc, diag::could_not_find_value_member, baseObjTy, memberName) .highlight(baseRange).highlight(nameLoc.getSourceRange()); }; // Check for a few common cases that can cause missing members. if (baseObjTy->is<EnumType>() && memberName.isSimpleName("rawValue")) { auto loc = baseObjTy->castTo<EnumType>()->getDecl()->getNameLoc(); if (loc.isValid()) { emitBasicError(); diagnose(loc, diag::did_you_mean_raw_type); return; } } else if (baseObjTy->isAny()) { emitBasicError(); diagnose(loc, diag::any_as_anyobject_fixit) .fixItInsert(baseExpr->getStartLoc(), "(") .fixItInsertAfter(baseExpr->getEndLoc(), " as AnyObject)"); return; } tryTypoCorrection(); if (auto correction = corrections.claimUniqueCorrection()) { auto diagnostic = diagnose(loc, diag::could_not_find_value_member_corrected, baseObjTy, memberName, correction->CorrectedName); diagnostic.highlight(baseRange).highlight(nameLoc.getSourceRange()); correction->addFixits(diagnostic); } else { emitBasicError(); } } // Note all the correction candidates. corrections.noteAllCandidates(); // TODO: recover? return; } // Otherwise, we have at least one (and potentially many) viable candidates // sort them out. If all of the candidates have the same problem (commonly // because there is exactly one candidate!) diagnose this. bool sameProblem = true; auto firstProblem = result.UnviableCandidates[0].second; ValueDecl *member = nullptr; for (auto cand : result.UnviableCandidates) { if (member == nullptr) member = cand.first.getDecl(); sameProblem &= cand.second == firstProblem; } auto instanceTy = baseObjTy; if (auto *MTT = instanceTy->getAs<AnyMetatypeType>()) instanceTy = MTT->getInstanceType(); if (sameProblem) { switch (firstProblem) { case MemberLookupResult::UR_LabelMismatch: break; case MemberLookupResult::UR_UnavailableInExistential: diagnose(loc, diag::could_not_use_member_on_existential, instanceTy, memberName) .highlight(baseRange).highlight(nameLoc.getSourceRange()); return; case MemberLookupResult::UR_InstanceMemberOnType: { // If the base is an implicit self type reference, and we're in a // an initializer, then the user wrote something like: // // class Foo { let x = 1, y = x } // // which runs in type context, not instance context, or // // class Bar { // let otherwise = 1 // instance member // var x: Int // func init(x: Int =otherwise) { // default parameter // self.x = x // } // } // // in which an instance member is used as a default value for a // parameter. // // Produce a tailored diagnostic for these cases since this // comes up and is otherwise non-obvious what is going on. if (baseExpr && baseExpr->isImplicit() && isa<Initializer>(CS.DC)) { auto *TypeDC = CS.DC->getParent(); bool propertyInitializer = true; // If the parent context is not a type context, we expect it // to be a defaulted parameter in a function declaration. if (!TypeDC->isTypeContext()) { assert(TypeDC->getContextKind() == DeclContextKind::AbstractFunctionDecl && "Expected function decl context for initializer!"); TypeDC = TypeDC->getParent(); propertyInitializer = false; } assert(TypeDC->isTypeContext() && "Expected type decl context!"); if (TypeDC->getSelfNominalTypeDecl() == instanceTy->getAnyNominal()) { if (propertyInitializer) CS.TC.diagnose(nameLoc, diag::instance_member_in_initializer, memberName); else CS.TC.diagnose(nameLoc, diag::instance_member_in_default_parameter, memberName); return; } } // Check whether the instance member is declared on parent context and if so // provide more specialized message. auto memberTypeContext = member->getDeclContext()->getInnermostTypeContext(); auto currentTypeContext = CS.DC->getInnermostTypeContext(); if (memberTypeContext && currentTypeContext && memberTypeContext->getSemanticDepth() < currentTypeContext->getSemanticDepth()) { diagnose(loc, diag::could_not_use_instance_member_on_type, currentTypeContext->getDeclaredInterfaceType(), memberName, memberTypeContext->getDeclaredInterfaceType(), true) .highlight(baseRange).highlight(nameLoc.getSourceRange()); } else { diagnose(loc, diag::could_not_use_instance_member_on_type, instanceTy, memberName, instanceTy, false) .highlight(baseRange).highlight(nameLoc.getSourceRange()); } return; } case MemberLookupResult::UR_TypeMemberOnInstance: diagnoseTypeMemberOnInstanceLookup(baseObjTy, baseExpr, memberName, nameLoc, member, loc); return; case MemberLookupResult::UR_MutatingMemberOnRValue: case MemberLookupResult::UR_MutatingGetterOnRValue: { auto diagIDsubelt = diag::cannot_pass_rvalue_mutating_subelement; auto diagIDmember = diag::cannot_pass_rvalue_mutating; if (firstProblem == MemberLookupResult::UR_MutatingGetterOnRValue) { diagIDsubelt = diag::cannot_pass_rvalue_mutating_getter_subelement; diagIDmember = diag::cannot_pass_rvalue_mutating_getter; } assert(baseExpr && "Cannot have a mutation failure without a base"); AssignmentFailure failure(baseExpr, CS, loc, diagIDsubelt, diagIDmember); (void)failure.diagnose(); return; } case MemberLookupResult::UR_Inaccessible: { auto decl = result.UnviableCandidates[0].first.getDecl(); // FIXME: What if the unviable candidates have different levels of access? // // If we found an inaccessible member of a protocol extension, it might // be declared 'public'. This can only happen if the protocol is not // visible to us, but the conforming type is. In this case, we need to // clamp the formal access for diagnostics purposes to the formal access // of the protocol itself. diagnose(nameLoc, diag::candidate_inaccessible, decl->getBaseName(), decl->getFormalAccessScope().accessLevelForDiagnostics()); for (auto cand : result.UnviableCandidates) diagnose(cand.first.getDecl(), diag::decl_declared_here, memberName); return; } } } // FIXME: Emit candidate set.... // Otherwise, we don't have a specific issue to diagnose. Just say the vague // 'cannot use' diagnostic. if (!baseObjTy->isEqual(instanceTy)) diagnose(loc, diag::could_not_use_type_member, instanceTy, memberName) .highlight(baseRange).highlight(nameLoc.getSourceRange()); else diagnose(loc, diag::could_not_use_value_member, baseObjTy, memberName) .highlight(baseRange).highlight(nameLoc.getSourceRange()); return; } // In the absence of a better conversion constraint failure, point out the // inability to find an appropriate overload. bool FailureDiagnosis::diagnoseGeneralOverloadFailure(Constraint *constraint) { Constraint *bindOverload = constraint; if (constraint->getKind() == ConstraintKind::Disjunction) bindOverload = constraint->getNestedConstraints().front(); auto overloadChoice = bindOverload->getOverloadChoice(); auto overloadName = overloadChoice.getName(); // Get the referenced expression from the failed constraint. auto anchor = expr; if (auto locator = bindOverload->getLocator()) { anchor = simplifyLocatorToAnchor(CS, locator); if (!anchor) return false; } // The anchor for the constraint is almost always an OverloadedDeclRefExpr or // UnresolvedDotExpr. Look at the parent node in the AST to find the Apply to // give a better diagnostic. Expr *call = expr->getParentMap()[anchor]; // We look through some simple things that get in between the overload set // and the apply. while (call && (isa<IdentityExpr>(call) || isa<TryExpr>(call) || isa<ForceTryExpr>(call))) { call = expr->getParentMap()[call]; } // FIXME: This is only needed because binops don't respect contextual types. if (call && isa<ApplyExpr>(call)) return false; // This happens, for example, with ambiguous OverloadedDeclRefExprs. We should // just implement visitOverloadedDeclRefExprs and nuke this. // If we couldn't resolve an argument, then produce a generic "ambiguity" // diagnostic. diagnose(anchor->getLoc(), diag::ambiguous_member_overload_set, overloadName) .highlight(anchor->getSourceRange()); if (constraint->getKind() == ConstraintKind::Disjunction) { for (auto elt : constraint->getNestedConstraints()) { if (elt->getKind() != ConstraintKind::BindOverload) continue; if (!elt->getOverloadChoice().isDecl()) continue; auto candidate = elt->getOverloadChoice().getDecl(); diagnose(candidate, diag::found_candidate); } } return true; } /// Produce a specialized diagnostic if this is an invalid conversion to Bool. bool FailureDiagnosis::diagnoseConversionToBool(Expr *expr, Type exprType) { // Check for "=" converting to Bool. The user probably meant ==. if (auto *AE = dyn_cast<AssignExpr>(expr->getValueProvidingExpr())) { diagnose(AE->getEqualLoc(), diag::use_of_equal_instead_of_equality) .fixItReplace(AE->getEqualLoc(), "==") .highlight(AE->getDest()->getLoc()) .highlight(AE->getSrc()->getLoc()); return true; } // If we're trying to convert something from optional type to Bool, then a // comparison against nil was probably expected. // TODO: It would be nice to handle "!x" --> x == false, but we have no way // to get to the parent expr at present. if (exprType->getOptionalObjectType()) { StringRef prefix = "(("; StringRef suffix = ") != nil)"; // Check if we need the inner parentheses. // Technically we only need them if there's something in 'expr' with // lower precedence than '!=', but the code actually comes out nicer // in most cases with parens on anything non-trivial. if (expr->canAppendPostfixExpression()) { prefix = prefix.drop_back(); suffix = suffix.drop_front(); } // FIXME: The outer parentheses may be superfluous too. diagnose(expr->getLoc(), diag::optional_used_as_boolean, exprType) .fixItInsert(expr->getStartLoc(), prefix) .fixItInsertAfter(expr->getEndLoc(), suffix); return true; } return false; } static bool diagnoseUnresolvedDotExprTypeRequirementFailure(ConstraintSystem &cs, Constraint *constraint) { auto &TC = cs.TC; auto *locator = constraint->getLocator(); if (!locator) return false; auto path = locator->getPath(); if (path.empty()) return false; auto &last = path.back(); if (last.getKind() != ConstraintLocator::TypeParameterRequirement) return false; auto *anchor = locator->getAnchor(); if (!anchor) return false; auto *UDE = dyn_cast<UnresolvedDotExpr>(anchor); if (!UDE) return false; auto ownerType = cs.getType(UDE->getBase()); if (!ownerType) return false; ownerType = cs.simplifyType(ownerType)->getWithoutSpecifierType(); if (ownerType->hasTypeVariable() || ownerType->hasUnresolvedType()) return false; // If we actually resolved the member to use, use it. auto loc = cs.getConstraintLocator(UDE, ConstraintLocator::Member); auto *member = cs.findResolvedMemberRef(loc); if (!member) return false; auto req = member->getAsGenericContext() ->getGenericSignature() ->getRequirements()[last.getValue()]; Diag<Type, Type, Type, Type, StringRef> note; switch (req.getKind()) { case RequirementKind::Conformance: case RequirementKind::Layout: return false; case RequirementKind::Superclass: note = diag::candidate_types_inheritance_requirement; break; case RequirementKind::SameType: note = diag::candidate_types_equal_requirement; break; } TC.diagnose(UDE->getLoc(), diag::could_not_find_value_member, ownerType, UDE->getName()); auto first = cs.simplifyType(constraint->getFirstType()); auto second = cs.simplifyType(constraint->getSecondType()); auto rawFirstType = req.getFirstType(); auto rawSecondType = req.getSecondType(); TC.diagnose(member, note, first, second, rawFirstType, rawSecondType, ""); return true; } /// Diagnose problems related to failures in constraints /// generated by `openGeneric` which represent different /// kinds of type parameter requirements. static bool diagnoseTypeRequirementFailure(ConstraintSystem &cs, Constraint *constraint) { auto &TC = cs.TC; auto *locator = constraint->getLocator(); if (!locator) return false; auto path = locator->getPath(); if (path.empty()) return false; auto &last = path.back(); if (last.getKind() != ConstraintLocator::TypeParameterRequirement) return false; auto *anchor = locator->getAnchor(); if (!anchor) return false; auto ownerType = cs.getType(anchor); if (isa<UnresolvedMemberExpr>(anchor)) ownerType = cs.getContextualType(); else if (auto *UDE = dyn_cast<UnresolvedDotExpr>(anchor)) ownerType = cs.getType(UDE->getBase()); if (!ownerType) return false; ownerType = cs.simplifyType(ownerType)->getWithoutSpecifierType(); if (ownerType->hasTypeVariable() || ownerType->hasUnresolvedType()) return false; if (diagnoseUnresolvedDotExprTypeRequirementFailure(cs, constraint)) return true; auto lhs = cs.simplifyType(constraint->getFirstType()); auto rhs = cs.simplifyType(constraint->getSecondType()); switch (constraint->getKind()) { case ConstraintKind::ConformsTo: TC.diagnose(anchor->getLoc(), diag::type_does_not_conform_owner, ownerType, lhs, rhs); return true; case ConstraintKind::Subtype: // superclass TC.diagnose(anchor->getLoc(), diag::type_does_not_inherit, ownerType, lhs, rhs); return true; case ConstraintKind::Equal: { // same type TC.diagnose(anchor->getLoc(), diag::types_not_equal, ownerType, lhs, rhs); return true; } default: break; } return false; } bool FailureDiagnosis::diagnoseGeneralConversionFailure(Constraint *constraint){ auto anchor = expr; bool resolvedAnchorToExpr = false; if (auto locator = constraint->getLocator()) { anchor = simplifyLocatorToAnchor(CS, locator); if (anchor) resolvedAnchorToExpr = true; else anchor = locator->getAnchor(); } Type fromType = CS.simplifyType(constraint->getFirstType()); if (fromType->hasTypeVariable() && resolvedAnchorToExpr) { TCCOptions options; // If we know we're removing a contextual constraint, then we can force a // type check of the subexpr because we know we're eliminating that // constraint. if (CS.getContextualTypePurpose() != CTP_Unused) options |= TCC_ForceRecheck; auto sub = typeCheckArbitrarySubExprIndependently(anchor, options); if (!sub) return true; fromType = CS.getType(sub); } // Bail on constraints that don't relate two types. if (constraint->getKind() == ConstraintKind::Disjunction || constraint->getKind() == ConstraintKind::BindOverload) return false; fromType = fromType->getRValueType(); auto toType = CS.simplifyType(constraint->getSecondType()); // Try to simplify irrelevant details of function types. For example, if // someone passes a "() -> Float" function to a "() throws -> Int" // parameter, then uttering the "throws" may confuse them into thinking that // that is the problem, even though there is a clear subtype relation. if (auto srcFT = fromType->getAs<FunctionType>()) if (auto destFT = toType->getAs<FunctionType>()) { auto destExtInfo = destFT->getExtInfo(); if (!srcFT->isNoEscape()) destExtInfo = destExtInfo.withNoEscape(false); if (!srcFT->throws()) destExtInfo = destExtInfo.withThrows(false); if (destExtInfo != destFT->getExtInfo()) toType = FunctionType::get(destFT->getParams(), destFT->getResult(), destExtInfo); // If this is a function conversion that discards throwability or // noescape, emit a specific diagnostic about that. if (srcFT->throws() && !destFT->throws()) { diagnose(expr->getLoc(), diag::throws_functiontype_mismatch, fromType, toType) .highlight(expr->getSourceRange()); return true; } if (srcFT->isNoEscape() && !destFT->isNoEscape()) { diagnose(expr->getLoc(), diag::noescape_functiontype_mismatch, fromType, toType) .highlight(expr->getSourceRange()); return true; } } // If this is a callee that mismatches an expected return type, we can emit a // very nice and specific error. In this case, what we'll generally see is // a failed conversion constraint of "A -> B" to "_ -> C", where the error is // that B isn't convertible to C. if (CS.getContextualTypePurpose() == CTP_CalleeResult) { auto destFT = toType->getAs<FunctionType>(); auto srcFT = fromType->getAs<FunctionType>(); if (destFT && srcFT && !isUnresolvedOrTypeVarType(srcFT->getResult())) { // Otherwise, the error is that the result types mismatch. diagnose(expr->getLoc(), diag::invalid_callee_result_type, srcFT->getResult(), destFT->getResult()) .highlight(expr->getSourceRange()); return true; } } // If simplification has turned this into the same types, then this isn't the // broken constraint that we're looking for. if (fromType->isEqual(toType) && constraint->getKind() != ConstraintKind::ConformsTo && constraint->getKind() != ConstraintKind::LiteralConformsTo) return false; // If we have two tuples with mismatching types, produce a tailored // diagnostic. if (auto fromTT = fromType->getAs<TupleType>()) if (auto toTT = toType->getAs<TupleType>()) { if (fromTT->getNumElements() != toTT->getNumElements()) { diagnose(anchor->getLoc(), diag::tuple_types_not_convertible_nelts, fromTT, toTT) .highlight(anchor->getSourceRange()); return true; } SmallVector<TupleTypeElt, 4> FromElts; auto voidTy = CS.getASTContext().TheUnresolvedType; for (unsigned i = 0, e = fromTT->getNumElements(); i != e; ++i) FromElts.push_back({ voidTy, fromTT->getElement(i).getName() }); auto TEType = TupleType::get(FromElts, CS.getASTContext()); SmallVector<int, 4> sources; SmallVector<unsigned, 4> variadicArgs; // If the shuffle conversion is invalid (e.g. incorrect element labels), // then we have a type error. if (computeTupleShuffle(TEType->castTo<TupleType>()->getElements(), toTT->getElements(), sources, variadicArgs)) { diagnose(anchor->getLoc(), diag::tuple_types_not_convertible, fromTT, toTT) .highlight(anchor->getSourceRange()); return true; } } // If the second type is a type variable, the expression itself is // ambiguous. Bail out so the general ambiguity diagnosing logic can handle // it. if (fromType->hasUnresolvedType() || fromType->hasTypeVariable() || toType->hasUnresolvedType() || toType->hasTypeVariable() || // FIXME: Why reject unbound generic types here? fromType->is<UnboundGenericType>()) return false; // Check for various issues converting to Bool. if (toType->isBool() && diagnoseConversionToBool(anchor, fromType)) return true; if (auto PT = toType->getAs<ProtocolType>()) { if (isa<NilLiteralExpr>(expr->getValueProvidingExpr())) { diagnose(expr->getLoc(), diag::cannot_use_nil_with_this_type, toType) .highlight(expr->getSourceRange()); return true; } // Emit a conformance error through conformsToProtocol. if (auto conformance = CS.TC.conformsToProtocol( fromType, PT->getDecl(), CS.DC, ConformanceCheckFlags::InExpression, expr->getLoc())) { if (conformance->isAbstract() || !conformance->getConcrete()->isInvalid()) return false; } return true; } // Due to migration reasons, types used to conform to BooleanType, which // contain a member var 'boolValue', now does not convert to Bool. This block // tries to add a specific diagnosis/fixit to explicitly invoke 'boolValue'. if (toType->isBool() && fromType->mayHaveMembers()) { auto LookupResult = CS.TC.lookupMember( CS.DC, fromType, DeclName(CS.TC.Context.getIdentifier("boolValue"))); if (!LookupResult.empty()) { if (isa<VarDecl>(LookupResult.begin()->getValueDecl())) { if (anchor->canAppendPostfixExpression()) diagnose(anchor->getLoc(), diag::types_not_convertible_use_bool_value, fromType, toType).fixItInsertAfter(anchor->getEndLoc(), ".boolValue"); else diagnose(anchor->getLoc(), diag::types_not_convertible_use_bool_value, fromType, toType).fixItInsert(anchor->getStartLoc(), "("). fixItInsertAfter(anchor->getEndLoc(), ").boolValue"); return true; } } } if (diagnoseTypeRequirementFailure(CS, constraint)) return true; diagnose(anchor->getLoc(), diag::types_not_convertible, constraint->getKind() == ConstraintKind::Subtype, fromType, toType) .highlight(anchor->getSourceRange()); // Check to see if this constraint came from a cast instruction. If so, // and if this conversion constraint is different than the types being cast, // produce a note that talks about the overall expression. // // TODO: Using parentMap would be more general, rather than requiring the // issue to be related to the root of the expr under study. if (auto ECE = dyn_cast<ExplicitCastExpr>(expr)) if (constraint->getLocator() && constraint->getLocator()->getAnchor() == ECE->getSubExpr()) { if (!toType->isEqual(ECE->getCastTypeLoc().getType())) diagnose(expr->getLoc(), diag::in_cast_expr_types, CS.getType(ECE->getSubExpr())->getRValueType(), ECE->getCastTypeLoc().getType()->getRValueType()) .highlight(ECE->getSubExpr()->getSourceRange()) .highlight(ECE->getCastTypeLoc().getSourceRange()); } return true; } namespace { class ExprTypeSaverAndEraser { llvm::DenseMap<Expr*, Type> ExprTypes; llvm::DenseMap<TypeLoc*, Type> TypeLocTypes; llvm::DenseMap<Pattern*, Type> PatternTypes; llvm::DenseMap<ParamDecl*, Type> ParamDeclTypes; llvm::DenseMap<ParamDecl*, Type> ParamDeclInterfaceTypes; llvm::DenseMap<CollectionExpr*, Expr*> CollectionSemanticExprs; llvm::DenseSet<ValueDecl*> PossiblyInvalidDecls; ExprTypeSaverAndEraser(const ExprTypeSaverAndEraser&) = delete; void operator=(const ExprTypeSaverAndEraser&) = delete; public: ExprTypeSaverAndEraser(Expr *E) { struct TypeSaver : public ASTWalker { ExprTypeSaverAndEraser *TS; TypeSaver(ExprTypeSaverAndEraser *TS) : TS(TS) {} std::pair<bool, Expr *> walkToExprPre(Expr *expr) override { TS->ExprTypes[expr] = expr->getType(); SWIFT_DEFER { assert((!expr->getType() || !expr->getType()->hasTypeVariable() // FIXME: We shouldn't allow these, either. || isa<LiteralExpr>(expr)) && "Type variable didn't get erased!"); }; // Preserve module expr type data to prevent further lookups. if (auto *declRef = dyn_cast<DeclRefExpr>(expr)) if (isa<ModuleDecl>(declRef->getDecl())) return { false, expr }; // Don't strip type info off OtherConstructorDeclRefExpr, because // CSGen doesn't know how to reconstruct it. if (isa<OtherConstructorDeclRefExpr>(expr)) return { false, expr }; // If a literal has a Builtin.Int or Builtin.FP type on it already, // then sema has already expanded out a call to // Init.init(<builtinliteral>) // and we don't want it to make // Init.init(Init.init(<builtinliteral>)) // preserve the type info to prevent this from happening. if (isa<LiteralExpr>(expr) && !isa<InterpolatedStringLiteralExpr>(expr) && !(expr->getType() && expr->getType()->hasError())) return { false, expr }; // If a ClosureExpr's parameter list has types on the decls, then // remove them so that they'll get regenerated from the // associated TypeLocs or resynthesized as fresh typevars. if (auto *CE = dyn_cast<ClosureExpr>(expr)) for (auto P : *CE->getParameters()) { if (P->hasType()) { TS->ParamDeclTypes[P] = P->getType(); P->setType(Type()); } if (P->hasInterfaceType()) { TS->ParamDeclInterfaceTypes[P] = P->getInterfaceType(); P->setInterfaceType(Type()); } TS->PossiblyInvalidDecls.insert(P); if (P->isInvalid()) P->setInvalid(false); } // If we have a CollectionExpr with a type checked SemanticExpr, // remove it so we can recalculate a new semantic form. if (auto *CE = dyn_cast<CollectionExpr>(expr)) { if (auto SE = CE->getSemanticExpr()) { TS->CollectionSemanticExprs[CE] = SE; CE->setSemanticExpr(nullptr); } } expr->setType(nullptr); return { true, expr }; } // If we find a TypeLoc (e.g. in an as? expr), save and erase it. bool walkToTypeLocPre(TypeLoc &TL) override { if (TL.getTypeRepr() && TL.getType()) { TS->TypeLocTypes[&TL] = TL.getType(); TL.setType(Type()); } return true; } std::pair<bool, Pattern*> walkToPatternPre(Pattern *P) override { if (P->hasType()) { TS->PatternTypes[P] = P->getType(); P->setType(Type()); } return { true, P }; } // Don't walk into statements. This handles the BraceStmt in // non-single-expr closures, so we don't walk into their body. std::pair<bool, Stmt *> walkToStmtPre(Stmt *S) override { return { false, S }; } }; E->walk(TypeSaver(this)); } void restore() { for (auto exprElt : ExprTypes) exprElt.first->setType(exprElt.second); for (auto typelocElt : TypeLocTypes) typelocElt.first->setType(typelocElt.second); for (auto patternElt : PatternTypes) patternElt.first->setType(patternElt.second); for (auto paramDeclElt : ParamDeclTypes) { assert(!paramDeclElt.first->isImmutable() || !paramDeclElt.second->is<InOutType>()); paramDeclElt.first->setType(paramDeclElt.second->getInOutObjectType()); } for (auto paramDeclIfaceElt : ParamDeclInterfaceTypes) { assert(!paramDeclIfaceElt.first->isImmutable() || !paramDeclIfaceElt.second->is<InOutType>()); paramDeclIfaceElt.first->setInterfaceType(paramDeclIfaceElt.second->getInOutObjectType()); } for (auto CSE : CollectionSemanticExprs) CSE.first->setSemanticExpr(CSE.second); if (!PossiblyInvalidDecls.empty()) for (auto D : PossiblyInvalidDecls) if (D->hasInterfaceType()) D->setInvalid(D->getInterfaceType()->hasError()); // Done, don't do redundant work on destruction. ExprTypes.clear(); TypeLocTypes.clear(); PatternTypes.clear(); PossiblyInvalidDecls.clear(); } // On destruction, if a type got wiped out, reset it from null to its // original type. This is helpful because type checking a subexpression // can lead to replacing the nodes in that subexpression. However, the // failed ConstraintSystem still has locators pointing to the old nodes, // and if expr-specific diagnostics fail to turn up anything useful to say, // we go digging through failed constraints, and expect their locators to // still be meaningful. ~ExprTypeSaverAndEraser() { for (auto CSE : CollectionSemanticExprs) if (!CSE.first->getType()) CSE.first->setSemanticExpr(CSE.second); for (auto exprElt : ExprTypes) if (!exprElt.first->getType()) exprElt.first->setType(exprElt.second); for (auto typelocElt : TypeLocTypes) if (!typelocElt.first->getType()) typelocElt.first->setType(typelocElt.second); for (auto patternElt : PatternTypes) if (!patternElt.first->hasType()) patternElt.first->setType(patternElt.second); for (auto paramDeclElt : ParamDeclTypes) if (!paramDeclElt.first->hasType()) { paramDeclElt.first->setType(getParamBaseType(paramDeclElt)); } for (auto paramDeclIfaceElt : ParamDeclInterfaceTypes) if (!paramDeclIfaceElt.first->hasInterfaceType()) { paramDeclIfaceElt.first->setInterfaceType( getParamBaseType(paramDeclIfaceElt)); } if (!PossiblyInvalidDecls.empty()) for (auto D : PossiblyInvalidDecls) if (D->hasInterfaceType()) D->setInvalid(D->getInterfaceType()->hasError()); } private: static Type getParamBaseType(std::pair<ParamDecl *, Type> &storedParam) { ParamDecl *param; Type storedType; std::tie(param, storedType) = storedParam; // FIXME: We are currently in process of removing `InOutType` // so `VarDecl::get{Interface}Type` is going to wrap base // type into `InOutType` if its flag indicates that it's // an `inout` parameter declaration. But such type can't // be restored directly using `VarDecl::set{Interface}Type` // caller needs additional logic to extract base type. if (auto *IOT = storedType->getAs<InOutType>()) { assert(param->isInOut()); return IOT->getObjectType(); } return storedType; } }; } // end anonymous namespace /// Unless we've already done this, retypecheck the specified subexpression on /// its own, without including any contextual constraints or parent expr /// nodes. This is more likely to succeed than type checking the original /// expression. /// /// This can return a new expression (for e.g. when a UnresolvedDeclRef gets /// resolved) and returns null when the subexpression fails to typecheck. Expr *FailureDiagnosis::typeCheckChildIndependently( Expr *subExpr, Type convertType, ContextualTypePurpose convertTypePurpose, TCCOptions options, ExprTypeCheckListener *listener, bool allowFreeTypeVariables) { // If this sub-expression is currently being diagnosed, refuse to recheck the // expression (which may lead to infinite recursion). If the client is // telling us that it knows what it is doing, then believe it. if (!options.contains(TCC_ForceRecheck)) { if (CS.TC.isExprBeingDiagnosed(subExpr)) { auto *savedExpr = CS.TC.getExprBeingDiagnosed(subExpr); if (subExpr == savedExpr) return subExpr; CS.cacheExprTypes(savedExpr); return savedExpr; } CS.TC.addExprForDiagnosis(subExpr, subExpr); } // Validate contextual type before trying to use it. std::tie(convertType, convertTypePurpose) = validateContextualType(convertType, convertTypePurpose); // If we have no contextual type information and the subexpr is obviously a // overload set, don't recursively simplify this. The recursive solver will // sometimes pick one based on arbitrary ranking behavior (e.g. like // which is the most specialized) even then all the constraints are being // fulfilled by UnresolvedType, which doesn't tell us anything. if (convertTypePurpose == CTP_Unused && (isa<OverloadedDeclRefExpr>(subExpr->getValueProvidingExpr()))) { return subExpr; } // Save any existing type data of the subexpr tree, and reset it to null in // prep for re-type-checking the tree. If things fail, we can revert the // types back to their original state. ExprTypeSaverAndEraser SavedTypeData(subExpr); // Store off the sub-expression, in case a new one is provided via the // type check operation. Expr *preCheckedExpr = subExpr; // Disable structural checks, because we know that the overall expression // has type constraint problems, and we don't want to know about any // syntactic issues in a well-typed subexpression (which might be because // the context is missing). TypeCheckExprOptions TCEOptions = TypeCheckExprFlags::DisableStructuralChecks; // Don't walk into non-single expression closure bodies, because // ExprTypeSaver and TypeNullifier skip them too. TCEOptions |= TypeCheckExprFlags::SkipMultiStmtClosures; // Claim that the result is discarded to preserve the lvalue type of // the expression. if (options.contains(TCC_AllowLValue)) TCEOptions |= TypeCheckExprFlags::IsDiscarded; // If there is no contextual type available, tell typeCheckExpression that it // is ok to produce an ambiguous result, it can just fill in holes with // UnresolvedType and we'll deal with it. if ((!convertType || options.contains(TCC_AllowUnresolvedTypeVariables)) && allowFreeTypeVariables) TCEOptions |= TypeCheckExprFlags::AllowUnresolvedTypeVariables; auto resultTy = CS.TC.typeCheckExpression( subExpr, CS.DC, TypeLoc::withoutLoc(convertType), convertTypePurpose, TCEOptions, listener, &CS); CS.cacheExprTypes(subExpr); // This is a terrible hack to get around the fact that typeCheckExpression() // might change subExpr to point to a new OpenExistentialExpr. In that case, // since the caller passed subExpr by value here, they would be left // holding on to an expression containing open existential types but // no OpenExistentialExpr, which breaks invariants enforced by the // ASTChecker. if (isa<OpenExistentialExpr>(subExpr)) eraseOpenedExistentials(CS, subExpr); // If recursive type checking failed, then an error was emitted. Return // null to indicate this to the caller. if (!resultTy) return nullptr; // If we type checked the result but failed to get a usable output from it, // just pretend as though nothing happened. if (resultTy->is<ErrorType>()) { subExpr = preCheckedExpr; if (subExpr->getType()) CS.cacheType(subExpr); SavedTypeData.restore(); } if (preCheckedExpr != subExpr) CS.TC.addExprForDiagnosis(preCheckedExpr, subExpr); return subExpr; } /// This is the same as typeCheckChildIndependently, but works on an arbitrary /// subexpression of the current node because it handles ClosureExpr parents /// of the specified node. Expr *FailureDiagnosis:: typeCheckArbitrarySubExprIndependently(Expr *subExpr, TCCOptions options) { if (subExpr == expr) return typeCheckChildIndependently(subExpr, options); // Construct a parent map for the expr tree we're investigating. auto parentMap = expr->getParentMap(); ClosureExpr *NearestClosure = nullptr; // Walk the parents of the specified expression, handling any ClosureExprs. for (Expr *node = parentMap[subExpr]; node; node = parentMap[node]) { auto *CE = dyn_cast<ClosureExpr>(node); if (!CE) continue; // Keep track of the innermost closure we see that we're jumping into. if (!NearestClosure) NearestClosure = CE; // If we have a ClosureExpr parent of the specified node, check to make sure // none of its arguments are type variables. If so, these type variables // would be accessible to name lookup of the subexpression and may thus leak // in. Reset them to UnresolvedTypes for safe measures. for (auto *param : *CE->getParameters()) { if (param->hasValidSignature()) { auto type = param->getType(); assert(!type->hasTypeVariable() && !type->hasError()); (void)type; } } } // When we're type checking a single-expression closure, we need to reset the // DeclContext to this closure for the recursive type checking. Otherwise, // if there is a closure in the subexpression, we can violate invariants. auto newDC = NearestClosure ? NearestClosure : CS.DC; llvm::SaveAndRestore<DeclContext *> SavedDC(CS.DC, newDC); // Otherwise, we're ok to type check the subexpr. return typeCheckChildIndependently(subExpr, options); } /// For an expression being type checked with a CTP_CalleeResult contextual /// type, try to diagnose a problem. bool FailureDiagnosis::diagnoseCalleeResultContextualConversionError() { // Try to dig out the conversion constraint in question to find the contextual // result type being specified. Type contextualResultType; for (auto &c : CS.getConstraints()) { if (!isConversionConstraint(&c) || !c.getLocator() || c.getLocator()->getAnchor() != expr) continue; // If we found our contextual type, then we know we have a conversion to // some function type, and that the result type is concrete. If not, // ignore it. auto toType = CS.simplifyType(c.getSecondType()); if (auto *FT = toType->getAs<AnyFunctionType>()) if (!isUnresolvedOrTypeVarType(FT->getResult())) { contextualResultType = FT->getResult(); break; } } if (!contextualResultType) return false; // Retypecheck the callee expression without a contextual type to resolve // whatever we can in it. auto callee = typeCheckChildIndependently(expr, TCC_ForceRecheck); if (!callee) return true; // Based on that, compute an overload set. CalleeCandidateInfo calleeInfo(callee, /*hasTrailingClosure*/false, CS); switch (calleeInfo.size()) { case 0: // If we found no overloads, then there is something else going on here. return false; case 1: // If the callee isn't of function type, then something else has gone wrong. if (!calleeInfo[0].getResultType()) return false; diagnose(expr->getLoc(), diag::candidates_no_match_result_type, calleeInfo.declName, calleeInfo[0].getResultType(), contextualResultType); return true; default: // Check to see if all of the viable candidates produce the same result, // this happens for things like "==" and "&&" operators. if (auto resultTy = calleeInfo[0].getResultType()) { for (unsigned i = 1, e = calleeInfo.size(); i != e; ++i) if (auto ty = calleeInfo[i].getResultType()) if (!resultTy->isEqual(ty)) { resultTy = Type(); break; } if (resultTy) { diagnose(expr->getLoc(), diag::candidates_no_match_result_type, calleeInfo.declName, calleeInfo[0].getResultType(), contextualResultType); return true; } } // Otherwise, produce a candidate set. diagnose(expr->getLoc(), diag::no_candidates_match_result_type, calleeInfo.declName, contextualResultType); calleeInfo.suggestPotentialOverloads(expr->getLoc(), /*isResult*/true); return true; } } /// Return true if the given type conforms to a known protocol type. static bool conformsToKnownProtocol(Type fromType, KnownProtocolKind kind, const ConstraintSystem &CS) { auto proto = CS.TC.getProtocol(SourceLoc(), kind); if (!proto) return false; if (CS.TC.conformsToProtocol(fromType, proto, CS.DC, ConformanceCheckFlags::InExpression)) { return true; } return false; } static bool isIntegerType(Type fromType, const ConstraintSystem &CS) { return conformsToKnownProtocol(fromType, KnownProtocolKind::ExpressibleByIntegerLiteral, CS); } /// Return true if the given type conforms to RawRepresentable. static Type isRawRepresentable(Type fromType, const ConstraintSystem &CS) { auto rawReprType = CS.TC.getProtocol(SourceLoc(), KnownProtocolKind::RawRepresentable); if (!rawReprType) return Type(); auto conformance = CS.TC.conformsToProtocol( fromType, rawReprType, CS.DC, ConformanceCheckFlags::InExpression); if (!conformance) return Type(); Type rawTy = ProtocolConformanceRef::getTypeWitnessByName( fromType, *conformance, CS.getASTContext().Id_RawValue, &CS.TC); return rawTy; } /// Return true if the given type conforms to RawRepresentable, with an /// underlying type conforming to the given known protocol. static Type isRawRepresentable(Type fromType, KnownProtocolKind kind, const ConstraintSystem &CS) { Type rawTy = isRawRepresentable(fromType, CS); if (!rawTy || !conformsToKnownProtocol(rawTy, kind, CS)) return Type(); return rawTy; } /// Return true if the conversion from fromType to toType is an invalid string /// index operation. static bool isIntegerToStringIndexConversion(Type fromType, Type toType, ConstraintSystem &CS) { auto kind = KnownProtocolKind::ExpressibleByIntegerLiteral; return (conformsToKnownProtocol(fromType, kind, CS) && toType->getCanonicalType().getString() == "String.CharacterView.Index"); } static bool isOptionSetType(Type fromType, const ConstraintSystem &CS) { return conformsToKnownProtocol(fromType, KnownProtocolKind::OptionSet, CS); } /// Attempts to add fix-its for these two mistakes: /// /// - Passing an integer where a type conforming to RawRepresentable is /// expected, by wrapping the expression in a call to the contextual /// type's initializer /// /// - Passing a type conforming to RawRepresentable where an integer is /// expected, by wrapping the expression in a call to the rawValue /// accessor /// /// - Return true on the fixit is added, false otherwise. /// /// This helps migration with SDK changes. static bool tryRawRepresentableFixIts(InFlightDiagnostic &diag, const ConstraintSystem &CS, Type fromType, Type toType, KnownProtocolKind kind, const Expr *expr) { // The following fixes apply for optional destination types as well. bool toTypeIsOptional = !toType->getOptionalObjectType().isNull(); toType = toType->lookThroughAllOptionalTypes(); Type fromTypeUnwrapped = fromType->getOptionalObjectType(); bool fromTypeIsOptional = !fromTypeUnwrapped.isNull(); if (fromTypeIsOptional) fromType = fromTypeUnwrapped; auto fixIt = [&](StringRef convWrapBefore, StringRef convWrapAfter) { SourceRange exprRange = expr->getSourceRange(); if (fromTypeIsOptional && toTypeIsOptional) { // Use optional's map function to convert conditionally, like so: // expr.map{ T(rawValue: $0) } bool needsParens = !expr->canAppendPostfixExpression(); std::string mapCodeFix; if (needsParens) { diag.fixItInsert(exprRange.Start, "("); mapCodeFix += ")"; } mapCodeFix += ".map { "; mapCodeFix += convWrapBefore; mapCodeFix += "$0"; mapCodeFix += convWrapAfter; mapCodeFix += " }"; diag.fixItInsertAfter(exprRange.End, mapCodeFix); } else if (!fromTypeIsOptional) { diag.fixItInsert(exprRange.Start, convWrapBefore); diag.fixItInsertAfter(exprRange.End, convWrapAfter); } else { SmallString<16> fixItBefore(convWrapBefore); SmallString<16> fixItAfter; if (!expr->canAppendPostfixExpression(true)) { fixItBefore += "("; fixItAfter = ")"; } fixItAfter += "!" + convWrapAfter.str(); diag.flush(); CS.TC .diagnose(expr->getLoc(), diag::construct_raw_representable_from_unwrapped_value, toType, fromType) .highlight(exprRange) .fixItInsert(exprRange.Start, fixItBefore) .fixItInsertAfter(exprRange.End, fixItAfter); } }; if (conformsToKnownProtocol(fromType, kind, CS)) { if (isOptionSetType(toType, CS) && isa<IntegerLiteralExpr>(expr) && cast<IntegerLiteralExpr>(expr)->getDigitsText() == "0") { diag.fixItReplace(expr->getSourceRange(), "[]"); return true; } if (auto rawTy = isRawRepresentable(toType, kind, CS)) { // Produce before/after strings like 'Result(rawValue: RawType(<expr>))' // or just 'Result(rawValue: <expr>)'. std::string convWrapBefore = toType.getString(); convWrapBefore += "(rawValue: "; std::string convWrapAfter = ")"; if (!isa<LiteralExpr>(expr) && !CS.TC.isConvertibleTo(fromType, rawTy, CS.DC)) { // Only try to insert a converting construction if the protocol is a // literal protocol and not some other known protocol. switch (kind) { #define EXPRESSIBLE_BY_LITERAL_PROTOCOL_WITH_NAME(name, _) \ case KnownProtocolKind::name: break; #define PROTOCOL_WITH_NAME(name, _) \ case KnownProtocolKind::name: return false; #include "swift/AST/KnownProtocols.def" } convWrapBefore += rawTy->getString(); convWrapBefore += "("; convWrapAfter += ")"; } fixIt(convWrapBefore, convWrapAfter); return true; } } if (auto rawTy = isRawRepresentable(fromType, kind, CS)) { if (conformsToKnownProtocol(toType, kind, CS)) { std::string convWrapBefore; std::string convWrapAfter = ".rawValue"; if (!CS.TC.isConvertibleTo(rawTy, toType, CS.DC)) { // Only try to insert a converting construction if the protocol is a // literal protocol and not some other known protocol. switch (kind) { #define EXPRESSIBLE_BY_LITERAL_PROTOCOL_WITH_NAME(name, _) \ case KnownProtocolKind::name: break; #define PROTOCOL_WITH_NAME(name, _) \ case KnownProtocolKind::name: return false; #include "swift/AST/KnownProtocols.def" } convWrapBefore += toType->getString(); convWrapBefore += "("; convWrapAfter += ")"; } fixIt(convWrapBefore, convWrapAfter); return true; } } return false; } /// Try to add a fix-it when converting between a collection and its slice type, /// such as String <-> Substring or (eventually) Array <-> ArraySlice static bool trySequenceSubsequenceConversionFixIts(InFlightDiagnostic &diag, ConstraintSystem &CS, Type fromType, Type toType, Expr *expr) { if (CS.TC.Context.getStdlibModule() == nullptr) return false; auto String = CS.TC.getStringType(CS.DC); auto Substring = CS.TC.getSubstringType(CS.DC); if (!String || !Substring) return false; /// FIXME: Remove this flag when void subscripts are implemented. /// Make this unconditional and remove the if statement. if (CS.TC.getLangOpts().FixStringToSubstringConversions) { // String -> Substring conversion // Add '[]' void subscript call to turn the whole String into a Substring if (fromType->isEqual(String)) { if (toType->isEqual(Substring)) { diag.fixItInsertAfter(expr->getEndLoc (), "[]"); return true; } } } // Substring -> String conversion // Wrap in String.init if (fromType->isEqual(Substring)) { if (toType->isEqual(String)) { auto range = expr->getSourceRange(); diag.fixItInsert(range.Start, "String("); diag.fixItInsertAfter(range.End, ")"); return true; } } return false; } /// Attempts to add fix-its for these two mistakes: /// /// - Passing an integer with the right type but which is getting wrapped with a /// different integer type unnecessarily. The fixit removes the cast. /// /// - Passing an integer but expecting different integer type. The fixit adds /// a wrapping cast. /// /// - Return true on the fixit is added, false otherwise. /// /// This helps migration with SDK changes. static bool tryIntegerCastFixIts(InFlightDiagnostic &diag, ConstraintSystem &CS, Type fromType, Type toType, Expr *expr) { if (!isIntegerType(fromType, CS) || !isIntegerType(toType, CS)) return false; auto getInnerCastedExpr = [&]() -> Expr * { if (auto *CE = dyn_cast<CoerceExpr>(expr)) return CE->getSubExpr(); auto *CE = dyn_cast<CallExpr>(expr); if (!CE) return nullptr; if (!isa<ConstructorRefCallExpr>(CE->getFn())) return nullptr; auto *parenE = dyn_cast<ParenExpr>(CE->getArg()); if (!parenE) return nullptr; return parenE->getSubExpr(); }; if (Expr *innerE = getInnerCastedExpr()) { Type innerTy = CS.getType(innerE); if (CS.TC.isConvertibleTo(innerTy, toType, CS.DC)) { // Remove the unnecessary cast. diag.fixItRemoveChars(expr->getLoc(), innerE->getStartLoc()) .fixItRemove(expr->getEndLoc()); return true; } } // Add a wrapping integer cast. std::string convWrapBefore = toType.getString(); convWrapBefore += "("; std::string convWrapAfter = ")"; SourceRange exprRange = expr->getSourceRange(); diag.fixItInsert(exprRange.Start, convWrapBefore); diag.fixItInsertAfter(exprRange.End, convWrapAfter); return true; } static bool addTypeCoerceFixit(InFlightDiagnostic &diag, ConstraintSystem &CS, Type fromType, Type toType, Expr *expr) { // Look through optional types; casts can add them, but can't remove extra // ones. bool bothOptional = fromType->getOptionalObjectType() && toType->getOptionalObjectType(); if (bothOptional) fromType = fromType->getOptionalObjectType(); toType = toType->lookThroughAllOptionalTypes(); CheckedCastKind Kind = CS.getTypeChecker().typeCheckCheckedCast( fromType, toType, CheckedCastContextKind::None, CS.DC, SourceLoc(), nullptr, SourceRange()); if (Kind != CheckedCastKind::Unresolved) { SmallString<32> buffer; llvm::raw_svector_ostream OS(buffer); bool canUseAs = Kind == CheckedCastKind::Coercion || Kind == CheckedCastKind::BridgingCoercion; if (bothOptional && canUseAs) toType = OptionalType::get(toType); toType->print(OS); diag.fixItInsert( Lexer::getLocForEndOfToken(CS.DC->getASTContext().SourceMgr, expr->getEndLoc()), (llvm::Twine(canUseAs ? " as " : " as! ") + OS.str()).str()); return true; } return false; } /// Try to diagnose common errors involving implicitly non-escaping parameters /// of function type, giving more specific and simpler diagnostics, attaching /// notes on the parameter, and offering fixits to insert @escaping. Returns /// true if it detects and issues an error, false if it does nothing. static bool tryDiagnoseNonEscapingParameterToEscaping( Expr *expr, Type srcType, Type dstType, ContextualTypePurpose dstPurpose, ConstraintSystem &CS) { assert(expr); // Need to be referencing a parameter of function type auto declRef = dyn_cast<DeclRefExpr>(expr); if (!declRef || !isa<ParamDecl>(declRef->getDecl()) || !CS.getType(declRef)->is<AnyFunctionType>()) return false; // Must be from non-escaping function to escaping function. For the // destination type, we read through optionality to give better diagnostics in // the event of an implicit promotion. auto srcFT = srcType->getAs<AnyFunctionType>(); auto dstFT = dstType->lookThroughAllOptionalTypes()->getAs<AnyFunctionType>(); if (!srcFT || !dstFT || !srcFT->isNoEscape() || dstFT->isNoEscape()) return false; // Pick a specific diagnostic for the specific use auto paramDecl = cast<ParamDecl>(declRef->getDecl()); switch (dstPurpose) { case CTP_CallArgument: CS.TC.diagnose(declRef->getLoc(), diag::passing_noescape_to_escaping, paramDecl->getName()); break; case CTP_AssignSource: CS.TC.diagnose(declRef->getLoc(), diag::assigning_noescape_to_escaping, paramDecl->getName()); break; default: CS.TC.diagnose(declRef->getLoc(), diag::general_noescape_to_escaping, paramDecl->getName()); break; } // Give a note and fixit InFlightDiagnostic note = CS.TC.diagnose( paramDecl->getLoc(), diag::noescape_parameter, paramDecl->getName()); if (!srcFT->isAutoClosure()) { note.fixItInsert(paramDecl->getTypeLoc().getSourceRange().Start, "@escaping "); } // TODO: add in a fixit for autoclosure return true; } bool FailureDiagnosis::diagnoseContextualConversionError( Expr *expr, Type contextualType, ContextualTypePurpose CTP, Type suggestedType) { // If the constraint system has a contextual type, then we can test to see if // this is the problem that prevents us from solving the system. if (!contextualType) { // This contextual conversion constraint doesn't install an actual type. if (CTP == CTP_CalleeResult) return diagnoseCalleeResultContextualConversionError(); return false; } // Try re-type-checking the expression without the contextual type to see if // it can work without it. If so, the contextual type is the problem. We // force a recheck, because "expr" is likely in our table with the extra // contextual constraint that we know we are relaxing. TCCOptions options = TCC_ForceRecheck; if (contextualType->is<InOutType>()) options |= TCC_AllowLValue; auto *recheckedExpr = typeCheckChildIndependently(expr, options); auto exprType = recheckedExpr ? CS.getType(recheckedExpr) : Type(); // If there is a suggested type and re-typecheck failed, let's use it. if (!exprType) exprType = suggestedType; // If it failed and diagnosed something, then we're done. if (!exprType) return CS.TC.Diags.hadAnyError(); // If we contextually had an inout type, and got a non-lvalue result, then // we fail with a mutability error. if (contextualType->is<InOutType>() && !exprType->is<LValueType>()) { AssignmentFailure failure(recheckedExpr, CS, recheckedExpr->getLoc(), diag::cannot_pass_rvalue_inout_subelement, diag::cannot_pass_rvalue_inout); return failure.diagnose(); } // Try to find the contextual type in a variety of ways. If the constraint // system had a contextual type specified, we use it - it will have a purpose // indicator which allows us to give a very "to the point" diagnostic. Diag<Type, Type> diagID; Diag<Type, Type> diagIDProtocol; Diag<Type> nilDiag; std::function<void(void)> nilFollowup; // If this is conversion failure due to a return statement with an argument // that cannot be coerced to the result type of the function, emit a // specific error. switch (CTP) { case CTP_Unused: case CTP_CannotFail: llvm_unreachable("These contextual type purposes cannot fail with a " "conversion type specified!"); case CTP_CalleeResult: llvm_unreachable("CTP_CalleeResult does not actually install a " "contextual type"); case CTP_Initialization: diagID = diag::cannot_convert_initializer_value; diagIDProtocol = diag::cannot_convert_initializer_value_protocol; nilDiag = diag::cannot_convert_initializer_value_nil; nilFollowup = [this] { TypeRepr *patternTR = CS.getContextualTypeLoc().getTypeRepr(); if (!patternTR) return; auto diag = diagnose(patternTR->getLoc(), diag::note_make_optional, OptionalType::get(CS.getContextualType())); if (patternTR->isSimple()) { diag.fixItInsertAfter(patternTR->getEndLoc(), "?"); } else { diag.fixItInsert(patternTR->getStartLoc(), "("); diag.fixItInsertAfter(patternTR->getEndLoc(), ")?"); } }; break; case CTP_ReturnStmt: // Special case the "conversion to void" case. if (contextualType->isVoid()) { diagnose(expr->getLoc(), diag::cannot_return_value_from_void_func) .highlight(expr->getSourceRange()); return true; } diagID = diag::cannot_convert_to_return_type; diagIDProtocol = diag::cannot_convert_to_return_type_protocol; nilDiag = diag::cannot_convert_to_return_type_nil; break; case CTP_ThrowStmt: { if (isa<NilLiteralExpr>(expr->getValueProvidingExpr())) { diagnose(expr->getLoc(), diag::cannot_throw_nil); return true; } if (isUnresolvedOrTypeVarType(exprType) || exprType->isEqual(contextualType)) return false; // If we tried to throw the error code of an error type, suggest object // construction. auto &TC = CS.getTypeChecker(); if (auto errorCodeProtocol = TC.Context.getProtocol(KnownProtocolKind::ErrorCodeProtocol)) { if (auto conformance = TC.conformsToProtocol(CS.getType(expr), errorCodeProtocol, CS.DC, ConformanceCheckFlags::InExpression)) { Type errorCodeType = CS.getType(expr); Type errorType = ProtocolConformanceRef::getTypeWitnessByName(errorCodeType, *conformance, TC.Context.Id_ErrorType, &TC)->getCanonicalType(); if (errorType) { auto diag = diagnose(expr->getLoc(), diag::cannot_throw_error_code, errorCodeType, errorType); if (auto unresolvedDot = dyn_cast<UnresolvedDotExpr>(expr)) { diag.fixItInsert(unresolvedDot->getDotLoc(), "("); diag.fixItInsertAfter(unresolvedDot->getEndLoc(), ")"); } return true; } } } // The conversion destination of throw is always ErrorType (at the moment) // if this ever expands, this should be a specific form like () is for // return. diagnose(expr->getLoc(), diag::cannot_convert_thrown_type, exprType) .highlight(expr->getSourceRange()); return true; } case CTP_EnumCaseRawValue: diagID = diag::cannot_convert_raw_initializer_value; diagIDProtocol = diag::cannot_convert_raw_initializer_value; nilDiag = diag::cannot_convert_raw_initializer_value_nil; break; case CTP_DefaultParameter: diagID = diag::cannot_convert_default_arg_value; diagIDProtocol = diag::cannot_convert_default_arg_value_protocol; nilDiag = diag::cannot_convert_default_arg_value_nil; break; case CTP_YieldByReference: if (auto contextualLV = contextualType->getAs<LValueType>()) contextualType = contextualLV->getObjectType(); if (auto exprLV = exprType->getAs<LValueType>()) { diagnose(expr->getLoc(), diag::cannot_yield_wrong_type_by_reference, exprLV->getObjectType(), contextualType); } else if (exprType->isEqual(contextualType)) { diagnose(expr->getLoc(), diag::cannot_yield_rvalue_by_reference_same_type, exprType); } else { diagnose(expr->getLoc(), diag::cannot_yield_rvalue_by_reference, exprType, contextualType); } return true; case CTP_YieldByValue: diagID = diag::cannot_convert_yield_value; diagIDProtocol = diag::cannot_convert_yield_value_protocol; nilDiag = diag::cannot_convert_yield_value_nil; break; case CTP_CallArgument: diagID = diag::cannot_convert_argument_value; diagIDProtocol = diag::cannot_convert_argument_value_protocol; nilDiag = diag::cannot_convert_argument_value_nil; break; case CTP_ClosureResult: diagID = diag::cannot_convert_closure_result; diagIDProtocol = diag::cannot_convert_closure_result_protocol; nilDiag = diag::cannot_convert_closure_result_nil; break; case CTP_ArrayElement: diagID = diag::cannot_convert_array_element; diagIDProtocol = diag::cannot_convert_array_element_protocol; nilDiag = diag::cannot_convert_array_element_nil; break; case CTP_DictionaryKey: diagID = diag::cannot_convert_dict_key; diagIDProtocol = diag::cannot_convert_dict_key_protocol; nilDiag = diag::cannot_convert_dict_key_nil; break; case CTP_DictionaryValue: diagID = diag::cannot_convert_dict_value; diagIDProtocol = diag::cannot_convert_dict_value_protocol; nilDiag = diag::cannot_convert_dict_value_nil; break; case CTP_CoerceOperand: diagID = diag::cannot_convert_coerce; diagIDProtocol = diag::cannot_convert_coerce_protocol; nilDiag = diag::cannot_convert_coerce_nil; break; case CTP_AssignSource: diagID = diag::cannot_convert_assign; diagIDProtocol = diag::cannot_convert_assign_protocol; nilDiag = diag::cannot_convert_assign_nil; break; } // If we're diagnostic an issue with 'nil', produce a specific diagnostic, // instead of uttering ExpressibleByNilLiteral. if (isa<NilLiteralExpr>(expr->getValueProvidingExpr())) { // If the source type is some kind of optional, the contextual conversion // to 'nil' didn't fail, something else did. if (contextualType->getOptionalObjectType()) return false; diagnose(expr->getLoc(), nilDiag, contextualType); if (nilFollowup) nilFollowup(); return true; } // If we don't have a type for the expression, then we cannot use it in // conversion constraint diagnostic generation. If the types match, then it // must not be the contextual type that is the problem. if (isUnresolvedOrTypeVarType(exprType) || exprType->isEqual(contextualType)) { return false; } // If we're trying to convert something of type "() -> T" to T, then we // probably meant to call the value. if (auto srcFT = exprType->getAs<AnyFunctionType>()) { if (srcFT->getParams().empty() && !isUnresolvedOrTypeVarType(srcFT->getResult()) && CS.TC.isConvertibleTo(srcFT->getResult(), contextualType, CS.DC)) { diagnose(expr->getLoc(), diag::missing_nullary_call, srcFT->getResult()) .highlight(expr->getSourceRange()) .fixItInsertAfter(expr->getEndLoc(), "()"); return true; } } // If this is a conversion from T to () in a call argument context, it is // almost certainly an extra argument being passed in. if (CTP == CTP_CallArgument && contextualType->isVoid()) { diagnose(expr->getLoc(), diag::extra_argument_to_nullary_call) .highlight(expr->getSourceRange()); return true; } // If we're trying to convert something to Bool, check to see if it is for // a known reason. if (contextualType->isBool() && diagnoseConversionToBool(expr, exprType)) return true; exprType = exprType->getRValueType(); // Special case of some common conversions involving Swift.String // indexes, catching cases where people attempt to index them with an integer. if (isIntegerToStringIndexConversion(exprType, contextualType, CS)) { diagnose(expr->getLoc(), diag::string_index_not_integer, exprType->getRValueType()) .highlight(expr->getSourceRange()); diagnose(expr->getLoc(), diag::string_index_not_integer_note); return true; } // When converting from T to [T] or UnsafePointer<T>, we can offer fixit to wrap // the expr with brackets. auto *genericType = contextualType->getAs<BoundGenericType>(); if (genericType) { auto *contextDecl = genericType->getDecl(); if (contextDecl == CS.TC.Context.getArrayDecl()) { for (Type arg : genericType->getGenericArgs()) { if (arg->isEqual(exprType)) { diagnose(expr->getLoc(), diagID, exprType, contextualType) .fixItInsert(expr->getStartLoc(), "[") .fixItInsert(Lexer::getLocForEndOfToken(CS.TC.Context.SourceMgr, expr->getEndLoc()), "]"); return true; } } } else if (contextDecl == CS.TC.Context.getUnsafePointerDecl() || contextDecl == CS.TC.Context.getUnsafeMutablePointerDecl() || contextDecl == CS.TC.Context.getUnsafeRawPointerDecl() || contextDecl == CS.TC.Context.getUnsafeMutableRawPointerDecl()) { for (Type arg : genericType->getGenericArgs()) { if (arg->isEqual(exprType) && CS.getType(expr)->hasLValueType()) { diagnose(expr->getLoc(), diagID, exprType, contextualType). fixItInsert(expr->getStartLoc(), "&"); return true; } } } } // Try for better/more specific diagnostics for non-escaping to @escaping if (tryDiagnoseNonEscapingParameterToEscaping(expr, exprType, contextualType, CTP, CS)) return true; // Don't attempt fixits if we have an unsolved type variable, since // the recovery path's recursion into the type checker via typeCheckCast() // will confuse matters. if (exprType->hasTypeVariable()) return false; // When complaining about conversion to a protocol type, complain about // conformance instead of "conversion". if (contextualType->is<ProtocolType>() || contextualType->is<ProtocolCompositionType>()) diagID = diagIDProtocol; // Try to simplify irrelevant details of function types. For example, if // someone passes a "() -> Float" function to a "() throws -> Int" // parameter, then uttering the "throws" may confuse them into thinking that // that is the problem, even though there is a clear subtype relation. if (auto srcFT = exprType->getAs<FunctionType>()) if (auto destFT = contextualType->getAs<FunctionType>()) { auto destExtInfo = destFT->getExtInfo(); if (!srcFT->isNoEscape()) destExtInfo = destExtInfo.withNoEscape(false); if (!srcFT->throws()) destExtInfo = destExtInfo.withThrows(false); if (destExtInfo != destFT->getExtInfo()) contextualType = FunctionType::get(destFT->getParams(), destFT->getResult(), destExtInfo); // If this is a function conversion that discards throwability or // noescape, emit a specific diagnostic about that. if (srcFT->throws() && !destFT->throws()) diagID = diag::throws_functiontype_mismatch; else if (srcFT->isNoEscape() && !destFT->isNoEscape()) diagID = diag::noescape_functiontype_mismatch; } InFlightDiagnostic diag = diagnose(expr->getLoc(), diagID, exprType, contextualType); diag.highlight(expr->getSourceRange()); // Try to convert between a sequence and its subsequence, notably // String <-> Substring. if (trySequenceSubsequenceConversionFixIts(diag, CS, exprType, contextualType, expr)) { return true; } // Attempt to add a fixit for the error. switch (CTP) { case CTP_CallArgument: case CTP_ArrayElement: case CTP_DictionaryKey: case CTP_DictionaryValue: case CTP_AssignSource: case CTP_Initialization: case CTP_ReturnStmt: tryRawRepresentableFixIts(diag, CS, exprType, contextualType, KnownProtocolKind::ExpressibleByIntegerLiteral, expr) || tryRawRepresentableFixIts(diag, CS, exprType, contextualType, KnownProtocolKind::ExpressibleByStringLiteral, expr) || tryIntegerCastFixIts(diag, CS, exprType, contextualType, expr) || addTypeCoerceFixit(diag, CS, exprType, contextualType, expr); break; default: // FIXME: Other contextual conversions too? break; } return true; } //===----------------------------------------------------------------------===// // Diagnose assigning variable to itself. //===----------------------------------------------------------------------===// static Decl *findSimpleReferencedDecl(const Expr *E) { if (auto *LE = dyn_cast<LoadExpr>(E)) E = LE->getSubExpr(); if (auto *DRE = dyn_cast<DeclRefExpr>(E)) return DRE->getDecl(); return nullptr; } static std::pair<Decl *, Decl *> findReferencedDecl(const Expr *E) { E = E->getValueProvidingExpr(); if (auto *LE = dyn_cast<LoadExpr>(E)) return findReferencedDecl(LE->getSubExpr()); if (auto *AE = dyn_cast<AssignExpr>(E)) return findReferencedDecl(AE->getDest()); if (auto *D = findSimpleReferencedDecl(E)) return std::make_pair(nullptr, D); if (auto *MRE = dyn_cast<MemberRefExpr>(E)) { if (auto *BaseDecl = findSimpleReferencedDecl(MRE->getBase())) return std::make_pair(BaseDecl, MRE->getMember().getDecl()); } return std::make_pair(nullptr, nullptr); } bool TypeChecker::diagnoseSelfAssignment(const Expr *E) { auto AE = dyn_cast<AssignExpr>(E); if (!AE) return false; auto LHSDecl = findReferencedDecl(AE->getDest()); auto RHSDecl = findReferencedDecl(AE->getSrc()); if (LHSDecl.second && LHSDecl == RHSDecl) { diagnose(AE->getLoc(), LHSDecl.first ? diag::self_assignment_prop : diag::self_assignment_var) .highlight(AE->getDest()->getSourceRange()) .highlight(AE->getSrc()->getSourceRange()); return true; } return false; } static bool isSymmetricBinaryOperator(const CalleeCandidateInfo &CCI) { // If we don't have at least one known candidate, don't trigger. if (CCI.candidates.empty()) return false; for (auto &candidate : CCI.candidates) { // Each candidate must be a non-assignment operator function. auto decl = dyn_cast_or_null<FuncDecl>(candidate.getDecl()); if (!decl) return false; auto op = dyn_cast_or_null<InfixOperatorDecl>(decl->getOperatorDecl()); if (!op || !op->getPrecedenceGroup() || op->getPrecedenceGroup()->isAssignment()) return false; // It must have exactly two parameters. auto params = decl->getParameters(); if (params->size() != 2) return false; // Require the types to be the same. if (!params->get(0)->getInterfaceType()->isEqual( params->get(1)->getInterfaceType())) return false; } return true; } /// Determine whether any of the given callee candidates have a default value. static bool candidatesHaveAnyDefaultValues( const CalleeCandidateInfo &candidates) { for (const auto &cand : candidates.candidates) { auto function = dyn_cast_or_null<AbstractFunctionDecl>(cand.getDecl()); if (!function) continue; if (function->hasImplicitSelfDecl()) { if (cand.level != 1) return false; } else { if (cand.level != 0) return false; } for (auto param : *function->getParameters()) { if (param->getDefaultArgumentKind() != DefaultArgumentKind::None) return true; } } return false; } /// Find the tuple element that can be initialized by a scalar. static Optional<unsigned> getElementForScalarInitOfArg( const TupleType *tupleTy, const CalleeCandidateInfo &candidates) { // Empty tuples cannot be initialized with a scalar. if (tupleTy->getNumElements() == 0) return None; auto getElementForScalarInitSimple = [](const TupleType *tupleTy) -> Optional<unsigned> { Optional<unsigned> result = None; for (unsigned i = 0, e = tupleTy->getNumElements(); i != e; ++i) { // If we already saw a non-vararg field, then we have more than // one candidate field. if (result.hasValue()) { // Vararg fields are okay; they'll just end up being empty. if (tupleTy->getElement(i).isVararg()) continue; // Give up. return None; } // Otherwise, remember this field number. result = i; } return result; }; // If there aren't any candidates, we're done. if (candidates.empty()) return getElementForScalarInitSimple(tupleTy); // Dig out the candidate. const auto &cand = candidates[0]; auto function = dyn_cast_or_null<AbstractFunctionDecl>(cand.getDecl()); if (!function) return getElementForScalarInitSimple(tupleTy); if (function->hasImplicitSelfDecl()) { if (cand.level != 1) return getElementForScalarInitSimple(tupleTy); } else { if (cand.level != 0) return getElementForScalarInitSimple(tupleTy); } auto paramList = function->getParameters(); if (tupleTy->getNumElements() != paramList->size()) return getElementForScalarInitSimple(tupleTy); // Find a tuple element without a default. Optional<unsigned> elementWithoutDefault; for (unsigned i : range(tupleTy->getNumElements())) { auto param = paramList->get(i); // Skip parameters with default arguments. if (param->getDefaultArgumentKind() != DefaultArgumentKind::None) continue; // If we already have an element without a default, check whether there are // two fields that need initialization. if (elementWithoutDefault) { // Variadic fields are okay; they'll just end up being empty. if (param->isVariadic()) continue; // If the element we saw before was variadic, it can be empty as well. auto priorParam = paramList->get(*elementWithoutDefault); if (!priorParam->isVariadic()) return None; } elementWithoutDefault = i; } if (elementWithoutDefault) return elementWithoutDefault; // All of the fields have default values; initialize the first one. return 0; } /// Return true if the argument of a CallExpr (or related node) has a trailing /// closure. static bool callArgHasTrailingClosure(Expr *E) { if (!E) return false; if (auto *PE = dyn_cast<ParenExpr>(E)) return PE->hasTrailingClosure(); else if (auto *TE = dyn_cast<TupleExpr>(E)) return TE->hasTrailingClosure(); return false; } /// Special magic to handle inout exprs and tuples in argument lists. Expr *FailureDiagnosis:: typeCheckArgumentChildIndependently(Expr *argExpr, Type argType, const CalleeCandidateInfo &candidates, TCCOptions options) { // Grab one of the candidates (if present) and get its input list to help // identify operators that have implicit inout arguments. Type exampleInputType; if (!candidates.empty()) { exampleInputType = candidates[0].getArgumentType(CS.getASTContext()); // If we found a single candidate, and have no contextually known argument // type information, use that one candidate as the type information for // subexpr checking. // // TODO: If all candidates have the same type for some argument, we could // pass down partial information. if (candidates.size() == 1 && !argType) argType = candidates[0].getArgumentType(CS.getASTContext()); } // If our candidates are instance members at curry level #0, then the argument // being provided is the receiver type for the instance. We produce better // diagnostics when we don't force the self type down. if (argType && !candidates.empty()) if (auto decl = candidates[0].getDecl()) if (decl->isInstanceMember() && candidates[0].level == 0 && !isa<SubscriptDecl>(decl)) argType = Type(); // Similarly, we get better results when we don't push argument types down // to symmetric operators. if (argType && isSymmetricBinaryOperator(candidates)) argType = Type(); // FIXME: This should all just be a matter of getting the type of the // sub-expression, but this doesn't work well when typeCheckChildIndependently // is over-conservative w.r.t. TupleExprs. auto *TE = dyn_cast<TupleExpr>(argExpr); if (!TE) { // If the argument isn't a tuple, it is some scalar value for a // single-argument call. if (exampleInputType && exampleInputType->is<InOutType>()) options |= TCC_AllowLValue; // If the argtype is a tuple type with default arguments, or a labeled tuple // with a single element, pull the scalar element type for the subexpression // out. If we can't do that and the tuple has default arguments, we have to // punt on passing down the type information, since type checking the // subexpression won't be able to find the default argument provider. if (argType) { if (auto argTT = argType->getAs<TupleType>()) { if (auto scalarElt = getElementForScalarInitOfArg(argTT, candidates)) { // If we found the single argument being initialized, use it. auto &arg = argTT->getElement(*scalarElt); // If the argument being specified is actually varargs, then we're // just specifying one element of a variadic list. Use the type of // the individual varargs argument, not the overall array type. if (arg.isVararg()) argType = arg.getVarargBaseTy(); else argType = arg.getType(); } else if (candidatesHaveAnyDefaultValues(candidates)) { argType = Type(); } } else if (candidatesHaveAnyDefaultValues(candidates)) { argType = Type(); } } auto CTPurpose = argType ? CTP_CallArgument : CTP_Unused; return typeCheckChildIndependently(argExpr, argType, CTPurpose, options); } // If we know the requested argType to use, use computeTupleShuffle to produce // the shuffle of input arguments to destination values. It requires a // TupleType to compute the mapping from argExpr. Conveniently, it doesn't // care about the actual types though, so we can just use 'void' for them. // FIXME: This doesn't need to be limited to tuple types. if (argType && argType->is<TupleType>()) { // Decompose the parameter type. SmallVector<AnyFunctionType::Param, 4> params; AnyFunctionType::decomposeInput(argType, params); // If we have a candidate function around, compute the position of its // default arguments. SmallBitVector defaultMap(params.size()); if (!candidates.empty()) { defaultMap = computeDefaultMap(params, candidates[0].getDecl(), candidates[0].level); } // Form a set of call arguments, using a dummy type (Void), because the // argument/parameter matching code doesn't need it. auto voidTy = CS.getASTContext().TheEmptyTupleType; SmallVector<AnyFunctionType::Param, 4> args; for (unsigned i = 0, e = TE->getNumElements(); i != e; ++i) { args.push_back(AnyFunctionType::Param(voidTy, TE->getElementName(i), {})); } /// Use a match call argument listener that allows relabeling. struct RelabelMatchCallArgumentListener : MatchCallArgumentListener { bool relabelArguments(ArrayRef<Identifier> newNames) override { return false; } } listener; SmallVector<ParamBinding, 4> paramBindings; if (!matchCallArguments(args, params, defaultMap, callArgHasTrailingClosure(argExpr), /*allowFixes=*/true, listener, paramBindings)) { SmallVector<Expr*, 4> resultElts(TE->getNumElements(), nullptr); SmallVector<TupleTypeElt, 4> resultEltTys(TE->getNumElements(), voidTy); // Perform analysis of the input elements. for (unsigned paramIdx : range(paramBindings.size())) { // Extract the parameter. const auto &param = params[paramIdx]; // Determine the parameter type. if (param.isInOut()) options |= TCC_AllowLValue; // Look at each of the arguments assigned to this parameter. auto currentParamType = param.getOldType(); for (auto inArgNo : paramBindings[paramIdx]) { // Determine the argument type. auto currentArgType = TE->getElement(inArgNo); auto exprResult = typeCheckChildIndependently(currentArgType, currentParamType, CTP_CallArgument, options); // If there was an error type checking this argument, then we're done. if (!exprResult) return nullptr; // If the caller expected something inout, but we didn't have // something of inout type, diagnose it. if (auto IOE = dyn_cast<InOutExpr>(exprResult->getSemanticsProvidingExpr())) { if (!param.isInOut()) { diagnose(exprResult->getLoc(), diag::extra_address_of, CS.getType(exprResult)->getInOutObjectType()) .highlight(exprResult->getSourceRange()) .fixItRemove(IOE->getStartLoc()); return nullptr; } } auto resultTy = CS.getType(exprResult); resultElts[inArgNo] = exprResult; resultEltTys[inArgNo] = {resultTy->getInOutObjectType(), TE->getElementName(inArgNo), ParameterTypeFlags().withInOut(resultTy->is<InOutType>())}; } } auto TT = TupleType::get(resultEltTys, CS.getASTContext()); return CS.cacheType(TupleExpr::create( CS.getASTContext(), TE->getLParenLoc(), resultElts, TE->getElementNames(), TE->getElementNameLocs(), TE->getRParenLoc(), TE->hasTrailingClosure(), TE->isImplicit(), TT)); } } // Get the simplified type of each element and rebuild the aggregate. SmallVector<TupleTypeElt, 4> resultEltTys; SmallVector<Expr*, 4> resultElts; TupleType *exampleInputTuple = nullptr; if (exampleInputType) exampleInputTuple = exampleInputType->getAs<TupleType>(); for (unsigned i = 0, e = TE->getNumElements(); i != e; i++) { if (exampleInputTuple && i < exampleInputTuple->getNumElements() && exampleInputTuple->getElement(i).isInOut()) options |= TCC_AllowLValue; auto elExpr = typeCheckChildIndependently(TE->getElement(i), options); if (!elExpr) return nullptr; // already diagnosed. resultElts.push_back(elExpr); auto resFlags = ParameterTypeFlags().withInOut(elExpr->isSemanticallyInOutExpr()); resultEltTys.push_back({CS.getType(elExpr)->getInOutObjectType(), TE->getElementName(i), resFlags}); } auto TT = TupleType::get(resultEltTys, CS.getASTContext()); return CS.cacheType(TupleExpr::create( CS.getASTContext(), TE->getLParenLoc(), resultElts, TE->getElementNames(), TE->getElementNameLocs(), TE->getRParenLoc(), TE->hasTrailingClosure(), TE->isImplicit(), TT)); } static DeclName getBaseName(DeclContext *context) { if (auto generic = context->getSelfNominalTypeDecl()) { return generic->getName(); } else if (context->isModuleScopeContext()) return context->getParentModule()->getName(); else llvm_unreachable("Unsupported base"); }; static void emitFixItForExplicitlyQualifiedReference( TypeChecker &tc, UnresolvedDotExpr *UDE, decltype(diag::fix_unqualified_access_top_level) diag, DeclName baseName, DescriptiveDeclKind kind) { auto name = baseName.getBaseIdentifier(); SmallString<32> namePlusDot = name.str(); namePlusDot.push_back('.'); tc.diagnose(UDE->getLoc(), diag, namePlusDot, kind, name) .fixItInsert(UDE->getStartLoc(), namePlusDot); } void ConstraintSystem::diagnoseDeprecatedConditionalConformanceOuterAccess( UnresolvedDotExpr *UDE, ValueDecl *choice) { auto result = TC.lookupUnqualified(DC, UDE->getName(), UDE->getLoc()); assert(result && "names can't just disappear"); // These should all come from the same place. auto exampleInner = result.front(); auto innerChoice = exampleInner.getValueDecl(); auto innerDC = exampleInner.getDeclContext()->getInnermostTypeContext(); auto innerParentDecl = innerDC->getSelfNominalTypeDecl(); auto innerBaseName = getBaseName(innerDC); auto choiceKind = choice->getDescriptiveKind(); auto choiceDC = choice->getDeclContext(); auto choiceBaseName = getBaseName(choiceDC); auto choiceParentDecl = choiceDC->getAsDecl(); auto choiceParentKind = choiceParentDecl ? choiceParentDecl->getDescriptiveKind() : DescriptiveDeclKind::Module; TC.diagnose(UDE->getLoc(), diag::warn_deprecated_conditional_conformance_outer_access, UDE->getName(), choiceKind, choiceParentKind, choiceBaseName, innerChoice->getDescriptiveKind(), innerParentDecl->getDescriptiveKind(), innerBaseName); emitFixItForExplicitlyQualifiedReference( TC, UDE, diag::fix_deprecated_conditional_conformance_outer_access, choiceBaseName, choiceKind); } static SmallVector<AnyFunctionType::Param, 4> decomposeArgType(Type argType, ArrayRef<Identifier> argLabels) { SmallVector<AnyFunctionType::Param, 4> result; AnyFunctionType::decomposeInput(argType, result); AnyFunctionType::relabelParams(result, argLabels); return result; } static bool diagnoseImplicitSelfErrors(Expr *fnExpr, Expr *argExpr, CalleeCandidateInfo &CCI, ArrayRef<Identifier> argLabels, ConstraintSystem &CS) { // If candidate list is empty it means that problem is somewhere else, // since we need to have candidates which might be shadowing other funcs. if (CCI.empty() || !CCI[0].getDecl()) return false; auto &TC = CS.TC; // Call expression is formed as 'foo.bar' where 'foo' might be an // implicit "Self" reference, such use wouldn't provide good diagnostics // for situations where instance members have equal names to functions in // Swift Standard Library e.g. min/max. auto UDE = dyn_cast<UnresolvedDotExpr>(fnExpr); if (!UDE) return false; auto baseExpr = dyn_cast<DeclRefExpr>(UDE->getBase()); if (!baseExpr) return false; auto baseDecl = baseExpr->getDecl(); if (!baseExpr->isImplicit() || baseDecl->getFullName() != TC.Context.Id_self) return false; // Our base expression is an implicit 'self.' reference e.g. // // extension Sequence { // func test() -> Int { // return max(1, 2) // } // } // // In this example the Sequence class already has two methods named 'max' // none of which accept two arguments, but there is a function in // Swift Standard Library called 'max' which does accept two arguments, // so user might have called that by mistake without realizing that // compiler would add implicit 'self.' prefix to the call of 'max'. auto argType = CS.getType(argExpr); // If argument wasn't properly type-checked, let's retry without changing AST. if (!argType || argType->hasUnresolvedType() || argType->hasTypeVariable() || argType->hasTypeParameter()) { auto *argTuple = dyn_cast<TupleExpr>(argExpr); if (!argTuple) { // Bail out if we don't have a well-formed argument list. return false; } // Let's type check individual argument expressions without any // contextual information to try to recover an argument type that // matches what the user actually wrote instead of what the typechecker // expects. SmallVector<TupleTypeElt, 4> elts; for (unsigned i = 0, e = argTuple->getNumElements(); i < e; ++i) { ConcreteDeclRef ref = nullptr; auto *el = argTuple->getElement(i); auto typeResult = TC.getTypeOfExpressionWithoutApplying(el, CS.DC, ref); if (!typeResult) return false; auto flags = ParameterTypeFlags().withInOut(typeResult->is<InOutType>()); elts.push_back(TupleTypeElt(typeResult->getInOutObjectType(), argTuple->getElementName(i), flags)); } argType = TupleType::get(elts, CS.getASTContext()); } auto typeKind = argType->getKind(); if (typeKind != TypeKind::Tuple && typeKind != TypeKind::Paren) return false; // If argument type couldn't be properly resolved or has errors, // we can't diagnose anything in here, it points to the different problem. if (isUnresolvedOrTypeVarType(argType) || argType->hasError()) return false; auto context = CS.DC; using CandidateMap = llvm::SmallDenseMap<ValueDecl *, llvm::SmallVector<OverloadChoice, 2>>; auto getBaseKind = [](ValueDecl *base) -> DescriptiveDeclKind { DescriptiveDeclKind kind = DescriptiveDeclKind::Module; if (!base) return kind; auto context = base->getDeclContext(); do { if (isa<ExtensionDecl>(context)) return DescriptiveDeclKind::Extension; if (auto nominal = dyn_cast<NominalTypeDecl>(context)) { kind = nominal->getDescriptiveKind(); break; } context = context->getParent(); } while (context); return kind; }; auto diagnoseShadowing = [&](ValueDecl *base, ArrayRef<OverloadChoice> candidates) -> bool { CalleeCandidateInfo calleeInfo(base ? base->getInterfaceType() : nullptr, candidates, CCI.hasTrailingClosure, CS, base); calleeInfo.filterListArgs(decomposeArgType(argType, argLabels)); auto diagnostic = diag::member_shadows_global_function_near_match; switch (calleeInfo.closeness) { case CC_Unavailable: case CC_Inaccessible: case CC_SelfMismatch: case CC_ArgumentLabelMismatch: case CC_ArgumentCountMismatch: case CC_GeneralMismatch: return false; case CC_NonLValueInOut: case CC_OneArgumentNearMismatch: case CC_OneArgumentMismatch: case CC_OneGenericArgumentNearMismatch: case CC_OneGenericArgumentMismatch: case CC_ArgumentNearMismatch: case CC_ArgumentMismatch: case CC_GenericNonsubstitutableMismatch: break; // Near match cases case CC_ExactMatch: diagnostic = diag::member_shadows_global_function; break; } auto choice = calleeInfo.candidates[0].getDecl(); auto baseKind = getBaseKind(base); auto baseName = getBaseName(choice->getDeclContext()); auto origCandidate = CCI[0].getDecl(); TC.diagnose(UDE->getLoc(), diagnostic, UDE->getName(), origCandidate->getDescriptiveKind(), origCandidate->getFullName(), choice->getDescriptiveKind(), choice->getFullName(), baseKind, baseName); auto topLevelDiag = diag::fix_unqualified_access_top_level; if (baseKind == DescriptiveDeclKind::Module) topLevelDiag = diag::fix_unqualified_access_top_level_multi; emitFixItForExplicitlyQualifiedReference(TC, UDE, topLevelDiag, baseName, choice->getDescriptiveKind()); for (auto &candidate : calleeInfo.candidates) { if (auto decl = candidate.getDecl()) TC.diagnose(decl, diag::decl_declared_here, decl->getFullName()); } return true; }; // For each of the parent contexts, let's try to find any candidates // which have the same name and the same number of arguments as callee. while (context->getParent()) { auto result = TC.lookupUnqualified(context, UDE->getName(), UDE->getLoc()); context = context->getParent(); if (!result || result.empty()) continue; CandidateMap candidates; for (const auto &candidate : result) { auto base = candidate.getBaseDecl(); auto decl = candidate.getValueDecl(); if ((base && base->isInvalid()) || decl->isInvalid()) continue; // If base is present but it doesn't represent a valid nominal, // we can't use current candidate as one of the choices. if (base && !base->getInterfaceType()->getNominalOrBoundGenericNominal()) continue; auto context = decl->getDeclContext(); // We are only interested in static or global functions, because // there is no way to call anything else properly. if (!decl->isStatic() && !context->isModuleScopeContext()) continue; OverloadChoice choice(base ? base->getInterfaceType() : nullptr, decl, UDE->getFunctionRefKind()); if (base) { // Let's group all of the candidates have a common base. candidates[base].push_back(choice); continue; } // If there is no base, it means this is one of the global functions, // let's try to diagnose its shadowing inline. if (diagnoseShadowing(base, choice)) return true; } if (candidates.empty()) continue; for (const auto &candidate : candidates) { if (diagnoseShadowing(candidate.getFirst(), candidate.getSecond())) return true; } } return false; } // It is a somewhat common error to try to access an instance method as a // curried member on the type, instead of using an instance, e.g. the user // wrote: // // Foo.doThing(42, b: 19) // // instead of: // // myFoo.doThing(42, b: 19) // // Check for this situation and handle it gracefully. static bool diagnoseInstanceMethodAsCurriedMemberOnType(CalleeCandidateInfo &CCI, Expr *fnExpr, Expr *argExpr) { for (auto &candidate : CCI.candidates) { if (!candidate.hasParameters()) return false; auto *decl = candidate.getDecl(); if (!decl) return false; // If this is an exact match at the level 1 of the parameters, but // there is still something wrong with the expression nevertheless // it might be worth while to check if it's instance method as curried // member of type problem. if (CCI.closeness == CC_ExactMatch && (decl->isInstanceMember() && candidate.level == 1)) continue; auto params = candidate.getParameters(); // If one of the candidates is an instance method with a single parameter // at the level 0, this might be viable situation for calling instance // method as curried member of type problem. if (params.size() != 1 || !decl->isInstanceMember() || candidate.level > 0) return false; } auto &TC = CCI.CS.TC; if (auto UDE = dyn_cast<UnresolvedDotExpr>(fnExpr)) { auto baseExpr = UDE->getBase(); auto baseType = CCI.CS.getType(baseExpr); if (auto *MT = baseType->getAs<MetatypeType>()) { auto DC = CCI.CS.DC; auto instanceType = MT->getInstanceType(); // If the base is an implicit self type reference, and we're in a // an initializer, then the user wrote something like: // // class Foo { let val = initFn() } // or // class Bar { func something(x: Int = initFn()) } // // which runs in type context, not instance context. Produce a tailored // diagnostic since this comes up and is otherwise non-obvious what is // going on. if (baseExpr->isImplicit() && isa<Initializer>(DC)) { auto *TypeDC = DC->getParent(); bool propertyInitializer = true; // If the parent context is not a type context, we expect it // to be a defaulted parameter in a function declaration. if (!TypeDC->isTypeContext()) { assert(TypeDC->getContextKind() == DeclContextKind::AbstractFunctionDecl && "Expected function decl context for initializer!"); TypeDC = TypeDC->getParent(); propertyInitializer = false; } assert(TypeDC->isTypeContext() && "Expected type decl context!"); if (TypeDC->getSelfNominalTypeDecl() == instanceType->getAnyNominal()) { if (propertyInitializer) TC.diagnose(UDE->getLoc(), diag::instance_member_in_initializer, UDE->getName()); else TC.diagnose(UDE->getLoc(), diag::instance_member_in_default_parameter, UDE->getName()); return true; } } // If this is a situation like this `self.foo(A())()` and self != A // let's say that `self` is not convertible to A. if (auto nominalType = CCI.CS.getType(argExpr)->getAs<NominalType>()) { if (!instanceType->isEqual(nominalType)) { TC.diagnose(argExpr->getStartLoc(), diag::types_not_convertible, false, nominalType, instanceType); return true; } } // Otherwise, complain about use of instance value on type. if (isa<TypeExpr>(baseExpr)) { TC.diagnose(UDE->getLoc(), diag::instance_member_use_on_type, instanceType, UDE->getName()) .highlight(baseExpr->getSourceRange()); } else { TC.diagnose(UDE->getLoc(), diag::could_not_use_instance_member_on_type, instanceType, UDE->getName(), instanceType, false) .highlight(baseExpr->getSourceRange()); } return true; } } return false; } static bool diagnoseTupleParameterMismatch(CalleeCandidateInfo &CCI, ArrayRef<AnyFunctionType::Param> params, ArrayRef<AnyFunctionType::Param> args, Expr *fnExpr, Expr *argExpr, bool isTopLevel = true) { // Try to diagnose function call tuple parameter splat only if // there is no trailing or argument closure, because // FailureDiagnosis::visitClosureExpr will produce better // diagnostic and fix-it for trailing closure case. if (isTopLevel) { if (CCI.hasTrailingClosure) return false; if (auto *parenExpr = dyn_cast<ParenExpr>(argExpr)) { if (isa<ClosureExpr>(parenExpr->getSubExpr())) return false; } } if (params.size() == 1 && args.size() == 1) { auto paramType = params.front().getOldType(); auto argType = args.front().getOldType(); if (auto *paramFnType = paramType->getAs<AnyFunctionType>()) { // Only if both of the parameter and argument types are functions // let's recur into diagnosing their arguments. if (auto *argFnType = argType->getAs<AnyFunctionType>()) return diagnoseTupleParameterMismatch(CCI, paramFnType->getParams(), argFnType->getParams(), fnExpr, argExpr, /* isTopLevel */ false); return false; } } if (params.size() != 1 || args.empty()) return false; auto paramType = params.front().getOldType(); if (args.size() == 1) { auto argType = args.front().getOldType(); if (auto *paramFnType = paramType->getAs<AnyFunctionType>()) { // Only if both of the parameter and argument types are functions // let's recur into diagnosing their arguments. if (auto *argFnType = argType->getAs<AnyFunctionType>()) return diagnoseTupleParameterMismatch(CCI, paramFnType->getParams(), argFnType->getParams(), fnExpr, argExpr, /* isTopLevel */ false); } return false; } // Let's see if inferred argument is actually a tuple inside of Paren. auto *paramTupleTy = paramType->getAs<TupleType>(); if (!paramTupleTy) return false; if (paramTupleTy->getNumElements() != args.size()) return false; // Looks like the number of tuple elements matches number // of function arguments, which means we can we can emit an // error about an attempt to make use of tuple splat or tuple // destructuring, unfortunately we can't provide a fix-it for // this case. auto &TC = CCI.CS.TC; if (isTopLevel) { if (auto *decl = CCI[0].getDecl()) { Identifier name; auto kind = decl->getDescriptiveKind(); // Constructors/descructors and subscripts don't really have names. if (!(isa<ConstructorDecl>(decl) || isa<DestructorDecl>(decl) || isa<SubscriptDecl>(decl))) { name = decl->getBaseName().getIdentifier(); } TC.diagnose(argExpr->getLoc(), diag::single_tuple_parameter_mismatch, kind, name, paramTupleTy, !name.empty()) .highlight(argExpr->getSourceRange()) .fixItInsertAfter(argExpr->getStartLoc(), "(") .fixItInsert(argExpr->getEndLoc(), ")"); } else { TC.diagnose(argExpr->getLoc(), diag::unknown_single_tuple_parameter_mismatch, paramTupleTy) .highlight(argExpr->getSourceRange()) .fixItInsertAfter(argExpr->getStartLoc(), "(") .fixItInsert(argExpr->getEndLoc(), ")"); } } else { TC.diagnose(argExpr->getLoc(), diag::nested_tuple_parameter_destructuring, paramTupleTy, CCI.CS.getType(fnExpr)); } return true; } static bool diagnoseTupleParameterMismatch(CalleeCandidateInfo &CCI, ArrayRef<FunctionType::Param> params, Type argType, Expr *fnExpr, Expr *argExpr, bool isTopLevel = true) { llvm::SmallVector<AnyFunctionType::Param, 4> args; FunctionType::decomposeInput(argType, args); return diagnoseTupleParameterMismatch(CCI, params, args, fnExpr, argExpr, isTopLevel); } class ArgumentMatcher : public MatchCallArgumentListener { TypeChecker &TC; Expr *FnExpr; Expr *ArgExpr; ArrayRef<AnyFunctionType::Param> &Parameters; const SmallBitVector &DefaultMap; SmallVectorImpl<AnyFunctionType::Param> &Arguments; CalleeCandidateInfo CandidateInfo; // Indicates if problem has been found and diagnostic was emitted. bool Diagnosed = false; // Indicates if functions we are trying to call is a subscript. bool IsSubscript; // Stores parameter bindings determined by call to matchCallArguments. SmallVector<ParamBinding, 4> Bindings; unsigned NumLabelFailures = 0; public: ArgumentMatcher(Expr *fnExpr, Expr *argExpr, ArrayRef<AnyFunctionType::Param> &params, const SmallBitVector &defaultMap, SmallVectorImpl<AnyFunctionType::Param> &args, CalleeCandidateInfo &CCI, bool isSubscript) : TC(CCI.CS.TC), FnExpr(fnExpr), ArgExpr(argExpr), Parameters(params), DefaultMap(defaultMap), Arguments(args), CandidateInfo(CCI), IsSubscript(isSubscript) {} void extraArgument(unsigned extraArgIdx) override { auto name = Arguments[extraArgIdx].getLabel(); Expr *arg = ArgExpr; auto tuple = dyn_cast<TupleExpr>(ArgExpr); if (tuple) arg = tuple->getElement(extraArgIdx); auto loc = arg->getLoc(); if (tuple && extraArgIdx == tuple->getNumElements() - 1 && tuple->hasTrailingClosure()) TC.diagnose(loc, diag::extra_trailing_closure_in_call) .highlight(arg->getSourceRange()); else if (Parameters.empty()) { auto Paren = dyn_cast<ParenExpr>(ArgExpr); Expr *SubExpr = nullptr; if (Paren) { SubExpr = Paren->getSubExpr(); } if (SubExpr && CandidateInfo.CS.getType(SubExpr) && CandidateInfo.CS.getType(SubExpr)->isVoid()) { TC.diagnose(loc, diag::extra_argument_to_nullary_call) .fixItRemove(SubExpr->getSourceRange()); } else { TC.diagnose(loc, diag::extra_argument_to_nullary_call) .highlight(ArgExpr->getSourceRange()); } } else if (name.empty()) TC.diagnose(loc, diag::extra_argument_positional) .highlight(arg->getSourceRange()); else TC.diagnose(loc, diag::extra_argument_named, name) .highlight(arg->getSourceRange()); Diagnosed = true; } void missingArgument(unsigned missingParamIdx) override { auto &param = Parameters[missingParamIdx]; Identifier name = param.getLabel(); // Search insertion index. unsigned argIdx = 0; for (int Idx = missingParamIdx - 1; Idx >= 0; --Idx) { if (Bindings[Idx].empty()) continue; argIdx = Bindings[Idx].back() + 1; break; } unsigned insertableEndIdx = Arguments.size(); if (CandidateInfo.hasTrailingClosure) insertableEndIdx -= 1; // Build argument string for fix-it. SmallString<32> insertBuf; llvm::raw_svector_ostream insertText(insertBuf); if (argIdx != 0) insertText << ", "; if (!name.empty()) insertText << name.str() << ": "; Type Ty = param.getOldType(); // Explode inout type. if (param.isInOut()) { insertText << "&"; Ty = param.getPlainType(); } // @autoclosure; the type should be the result type. if (auto FT = param.getOldType()->getAs<AnyFunctionType>()) if (FT->isAutoClosure()) Ty = FT->getResult(); insertText << "<#" << Ty << "#>"; if (argIdx == 0 && insertableEndIdx != 0) insertText << ", "; SourceLoc insertLoc; if (argIdx > insertableEndIdx) { // Unreachable for now. // FIXME: matchCallArguments() doesn't detect "missing argument after // trailing closure". E.g. // func fn(x: Int, y: () -> Int, z: Int) { ... } // fn(x: 1) { return 1 } // is diagnosed as "missing argument for 'y'" (missingParamIdx 1). // It should be "missing argument for 'z'" (missingParamIdx 2). } else if (auto *TE = dyn_cast<TupleExpr>(ArgExpr)) { // fn(): // fn([argMissing]) // fn(argX, argY): // fn([argMissing, ]argX, argY) // fn(argX[, argMissing], argY) // fn(argX, argY[, argMissing]) // fn(argX) { closure }: // fn([argMissing, ]argX) { closure } // fn(argX[, argMissing]) { closure } // fn(argX[, closureLabel: ]{closure}[, argMissing)] // Not impl. if (insertableEndIdx == 0) insertLoc = TE->getRParenLoc(); else if (argIdx != 0) insertLoc = Lexer::getLocForEndOfToken( TC.Context.SourceMgr, TE->getElement(argIdx - 1)->getEndLoc()); else { insertLoc = TE->getElementNameLoc(0); if (insertLoc.isInvalid()) insertLoc = TE->getElement(0)->getStartLoc(); } } else if (auto *PE = dyn_cast<ParenExpr>(ArgExpr)) { assert(argIdx <= 1); if (PE->getRParenLoc().isValid()) { // fn(argX): // fn([argMissing, ]argX) // fn(argX[, argMissing]) // fn() { closure }: // fn([argMissing]) {closure} // fn([closureLabel: ]{closure}[, argMissing]) // Not impl. if (insertableEndIdx == 0) insertLoc = PE->getRParenLoc(); else if (argIdx == 0) insertLoc = PE->getSubExpr()->getStartLoc(); else insertLoc = Lexer::getLocForEndOfToken(TC.Context.SourceMgr, PE->getSubExpr()->getEndLoc()); } else { // fn { closure }: // fn[(argMissing)] { closure } // fn[(closureLabel:] { closure }[, missingArg)] // Not impl. assert(!IsSubscript && "bracket less subscript"); assert(PE->hasTrailingClosure() && "paren less ParenExpr without trailing closure"); insertBuf.insert(insertBuf.begin(), '('); insertBuf.insert(insertBuf.end(), ')'); insertLoc = Lexer::getLocForEndOfToken(TC.Context.SourceMgr, FnExpr->getEndLoc()); } } else { auto &CS = CandidateInfo.CS; (void)CS; // FIXME: Due to a quirk of CSApply, we can end up without a // ParenExpr if the argument has an '@lvalue TupleType'. assert((isa<TupleType>(CS.getType(ArgExpr).getPointer()) || CS.getType(ArgExpr)->hasParenSugar()) && "unexpected argument expression type"); insertLoc = ArgExpr->getLoc(); // Can't be TupleShuffleExpr because this argExpr is not yet resolved. } assert(insertLoc.isValid() && "missing argument after trailing closure?"); if (name.empty()) TC.diagnose(insertLoc, diag::missing_argument_positional, missingParamIdx + 1) .fixItInsert(insertLoc, insertText.str()); else TC.diagnose(insertLoc, diag::missing_argument_named, name) .fixItInsert(insertLoc, insertText.str()); auto candidate = CandidateInfo[0]; if (candidate.getDecl()) TC.diagnose(candidate.getDecl(), diag::decl_declared_here, candidate.getDecl()->getFullName()); Diagnosed = true; } bool missingLabel(unsigned paramIdx) override { ++NumLabelFailures; return false; } bool extraneousLabel(unsigned paramIdx) override { ++NumLabelFailures; return false; } bool incorrectLabel(unsigned paramIdx) override { ++NumLabelFailures; return false; } void outOfOrderArgument(unsigned argIdx, unsigned prevArgIdx) override { auto tuple = cast<TupleExpr>(ArgExpr); Identifier first = tuple->getElementName(argIdx); Identifier second = tuple->getElementName(prevArgIdx); // If we've seen label failures and now there is an out-of-order // parameter (or even worse - OoO parameter with label re-naming), // we most likely have no idea what would be the best // diagnostic for this situation, so let's just try to re-label. auto shouldDiagnoseOoO = [&](Identifier newLabel, Identifier oldLabel) { if (NumLabelFailures > 0) return false; unsigned actualIndex = prevArgIdx; for (; actualIndex != argIdx; ++actualIndex) { // Looks like new position (excluding defaulted parameters), // has a valid label. if (newLabel == Parameters[actualIndex].getLabel()) break; // If we are moving the the position with a different label // and there is no default value for it, can't diagnose the // problem as a simple re-ordering. if (!DefaultMap.test(actualIndex)) return false; } for (unsigned i = actualIndex + 1, n = Parameters.size(); i != n; ++i) { if (oldLabel == Parameters[i].getLabel()) break; if (!DefaultMap.test(i)) return false; } return true; }; if (!shouldDiagnoseOoO(first, second)) { SmallVector<Identifier, 8> paramLabels; llvm::transform(Parameters, std::back_inserter(paramLabels), [](const AnyFunctionType::Param &param) { return param.getLabel(); }); relabelArguments(paramLabels); return; } // Build a mapping from arguments to parameters. SmallVector<unsigned, 4> argBindings(tuple->getNumElements()); for (unsigned paramIdx = 0; paramIdx != Bindings.size(); ++paramIdx) { for (auto argIdx : Bindings[paramIdx]) argBindings[argIdx] = paramIdx; } auto argRange = [&](unsigned argIdx, Identifier label) -> SourceRange { auto range = tuple->getElement(argIdx)->getSourceRange(); if (!label.empty()) range.Start = tuple->getElementNameLoc(argIdx); unsigned paramIdx = argBindings[argIdx]; if (Bindings[paramIdx].size() > 1) range.End = tuple->getElement(Bindings[paramIdx].back())->getEndLoc(); return range; }; auto firstRange = argRange(argIdx, first); auto secondRange = argRange(prevArgIdx, second); SourceLoc diagLoc = firstRange.Start; auto addFixIts = [&](InFlightDiagnostic diag) { diag.highlight(firstRange).highlight(secondRange); // Move the misplaced argument by removing it from one location and // inserting it in another location. To maintain argument comma // separation, since the argument is always moving to an earlier index // the preceding comma and whitespace is removed and a new trailing // comma and space is inserted with the moved argument. auto &SM = TC.Context.SourceMgr; auto text = SM.extractText( Lexer::getCharSourceRangeFromSourceRange(SM, firstRange)); auto removalRange = SourceRange(Lexer::getLocForEndOfToken( SM, tuple->getElement(argIdx - 1)->getEndLoc()), firstRange.End); diag.fixItRemove(removalRange); diag.fixItInsert(secondRange.Start, text.str() + ", "); }; // There are 4 diagnostic messages variations depending on // labeled/unlabeled arguments. if (first.empty() && second.empty()) { addFixIts(TC.diagnose(diagLoc, diag::argument_out_of_order_unnamed_unnamed, argIdx + 1, prevArgIdx + 1)); } else if (first.empty() && !second.empty()) { addFixIts(TC.diagnose(diagLoc, diag::argument_out_of_order_unnamed_named, argIdx + 1, second)); } else if (!first.empty() && second.empty()) { addFixIts(TC.diagnose(diagLoc, diag::argument_out_of_order_named_unnamed, first, prevArgIdx + 1)); } else { addFixIts(TC.diagnose(diagLoc, diag::argument_out_of_order_named_named, first, second)); } Diagnosed = true; } bool relabelArguments(ArrayRef<Identifier> newNames) override { assert(!newNames.empty() && "No arguments were re-labeled"); // Let's diagnose labeling problem but only related to corrected ones. if (diagnoseArgumentLabelError(TC.Context, ArgExpr, newNames, IsSubscript)) Diagnosed = true; return true; } bool diagnose() { // Use matchCallArguments to determine how close the argument list is (in // shape) to the specified candidates parameters. This ignores the // concrete types of the arguments, looking only at the argument labels. matchCallArguments(Arguments, Parameters, DefaultMap, CandidateInfo.hasTrailingClosure, /*allowFixes:*/ true, *this, Bindings); return Diagnosed; } }; /// Emit a class of diagnostics that we only know how to generate when /// there is exactly one candidate we know about. Return true if an error /// is emitted. static bool diagnoseSingleCandidateFailures(CalleeCandidateInfo &CCI, Expr *fnExpr, Expr *argExpr, ArrayRef<Identifier> argLabels) { // We only handle the situation where there is exactly one candidate // here. if (CCI.size() != 1) return false; auto candidate = CCI[0]; auto &TC = CCI.CS.TC; if (!candidate.hasParameters()) return false; auto params = candidate.getParameters(); SmallBitVector defaultMap = computeDefaultMap(params, candidate.getDecl(), candidate.level); auto args = decomposeArgType(CCI.CS.getType(argExpr), argLabels); // Check the case where a raw-representable type is constructed from an // argument with the same type: // // MyEnumType(MyEnumType.foo) // // This is missing 'rawValue:' label, but a better fix is to just remove // the unnecessary constructor call: // // MyEnumType.foo // if (params.size() == 1 && args.size() == 1 && candidate.getDecl() && isa<ConstructorDecl>(candidate.getDecl()) && candidate.level == 1) { AnyFunctionType::Param &arg = args[0]; auto resTy = candidate.getResultType()->lookThroughAllOptionalTypes(); auto rawTy = isRawRepresentable(resTy, CCI.CS); if (rawTy && arg.getOldType() && resTy->isEqual(arg.getOldType())) { auto getInnerExpr = [](Expr *E) -> Expr * { auto *parenE = dyn_cast<ParenExpr>(E); if (!parenE) return nullptr; return parenE->getSubExpr(); }; Expr *innerE = getInnerExpr(argExpr); InFlightDiagnostic diag = TC.diagnose( fnExpr->getLoc(), diag::invalid_initialization_parameter_same_type, resTy); diag.highlight((innerE ? innerE : argExpr)->getSourceRange()); if (innerE) { // Remove the unnecessary constructor call. diag.fixItRemoveChars(fnExpr->getLoc(), innerE->getStartLoc()) .fixItRemove(argExpr->getEndLoc()); } return true; } } if (diagnoseTupleParameterMismatch(CCI, candidate.getParameters(), CCI.CS.getType(argExpr), fnExpr, argExpr)) return true; // We only handle structural errors here. if (CCI.closeness != CC_ArgumentLabelMismatch && CCI.closeness != CC_ArgumentCountMismatch) return false; // If we have a single candidate that failed to match the argument list, // attempt to use matchCallArguments to diagnose the problem. return ArgumentMatcher(fnExpr, argExpr, params, defaultMap, args, CCI, isa<SubscriptExpr>(fnExpr)) .diagnose(); } namespace { enum class RawRepresentableMismatch { NotApplicable, Convertible, ExactMatch }; } static RawRepresentableMismatch checkRawRepresentableMismatch(Type fromType, Type toType, KnownProtocolKind kind, const ConstraintSystem &CS) { toType = toType->lookThroughAllOptionalTypes(); fromType = fromType->lookThroughAllOptionalTypes(); // First check if this is an attempt to convert from something to // raw representable. if (conformsToKnownProtocol(fromType, kind, CS)) { if (auto rawType = isRawRepresentable(toType, kind, CS)) { if (rawType->isEqual(fromType)) return RawRepresentableMismatch::ExactMatch; return RawRepresentableMismatch::Convertible; } } // Otherwise, it might be an attempt to convert from raw representable // to its raw value. if (auto rawType = isRawRepresentable(fromType, kind, CS)) { if (conformsToKnownProtocol(toType, kind, CS)) { if (rawType->isEqual(toType)) return RawRepresentableMismatch::ExactMatch; return RawRepresentableMismatch::Convertible; } } return RawRepresentableMismatch::NotApplicable; } static bool diagnoseRawRepresentableMismatch(CalleeCandidateInfo &CCI, Expr *argExpr, ArrayRef<Identifier> argLabels) { // We are only interested in cases which are // unrelated to argument count or label mismatches. switch (CCI.closeness) { case CC_OneArgumentNearMismatch: case CC_OneArgumentMismatch: case CC_OneGenericArgumentNearMismatch: case CC_OneGenericArgumentMismatch: case CC_ArgumentNearMismatch: case CC_ArgumentMismatch: break; default: return false; } auto argType = CCI.CS.getType(argExpr); if (!argType || argType->hasTypeVariable() || argType->hasUnresolvedType()) return false; KnownProtocolKind rawRepresentableProtocols[] = { KnownProtocolKind::ExpressibleByStringLiteral, KnownProtocolKind::ExpressibleByIntegerLiteral}; const auto &CS = CCI.CS; auto arguments = decomposeArgType(argType, argLabels); auto bestMatchKind = RawRepresentableMismatch::NotApplicable; const UncurriedCandidate *bestMatchCandidate = nullptr; KnownProtocolKind bestMatchProtocol; size_t bestMatchIndex; for (auto &candidate : CCI.candidates) { auto *decl = candidate.getDecl(); if (!decl) continue; if (!candidate.hasParameters()) continue; auto parameters = candidate.getParameters(); // FIXME: Default arguments? if (parameters.size() != arguments.size()) continue; for (unsigned i = 0, n = parameters.size(); i != n; ++i) { auto paramType = parameters[i].getOldType(); auto argType = arguments[i].getOldType(); for (auto kind : rawRepresentableProtocols) { // If trying to convert from raw type to raw representable, // or vice versa from raw representable (e.g. enum) to raw type. auto matchKind = checkRawRepresentableMismatch(argType, paramType, kind, CS); if (matchKind > bestMatchKind) { bestMatchKind = matchKind; bestMatchProtocol = kind; bestMatchCandidate = &candidate; bestMatchIndex = i; } } } } if (bestMatchKind == RawRepresentableMismatch::NotApplicable) return false; const Expr *expr = argExpr; if (auto *tupleArgs = dyn_cast<TupleExpr>(argExpr)) expr = tupleArgs->getElement(bestMatchIndex); expr = expr->getValueProvidingExpr(); auto parameters = bestMatchCandidate->getParameters(); auto paramType = parameters[bestMatchIndex].getOldType(); auto singleArgType = arguments[bestMatchIndex].getOldType(); auto diag = CS.TC.diagnose(expr->getLoc(), diag::cannot_convert_argument_value, singleArgType, paramType); tryRawRepresentableFixIts(diag, CS, singleArgType, paramType, bestMatchProtocol, expr); return true; } // Extract expression for failed argument number static Expr *getFailedArgumentExpr(CalleeCandidateInfo CCI, Expr *argExpr) { if (auto *TE = dyn_cast<TupleExpr>(argExpr)) return TE->getElement(CCI.failedArgument.argumentNumber); else if (auto *PE = dyn_cast<ParenExpr>(argExpr)) { assert(CCI.failedArgument.argumentNumber == 0 && "Unexpected argument #"); return PE->getSubExpr(); } else { assert(CCI.failedArgument.argumentNumber == 0 && "Unexpected argument #"); return argExpr; } } /// If the candidate set has been narrowed down to a specific structural /// problem, e.g. that there are too few parameters specified or that argument /// labels don't match up, diagnose that error and return true. bool FailureDiagnosis::diagnoseParameterErrors(CalleeCandidateInfo &CCI, Expr *fnExpr, Expr *argExpr, ArrayRef<Identifier> argLabels) { if (auto *MTT = CS.getType(fnExpr)->getAs<MetatypeType>()) { auto instTy = MTT->getInstanceType(); if (instTy->getAnyNominal()) { // If we are invoking a constructor on a nominal type and there are // absolutely no candidates, then they must all be private. if (CCI.empty() || (CCI.size() == 1 && CCI.candidates[0].getDecl() && isa<ProtocolDecl>(CCI.candidates[0].getDecl()))) { CS.TC.diagnose(fnExpr->getLoc(), diag::no_accessible_initializers, instTy); return true; } // continue below } else if (!instTy->is<TupleType>()) { // If we are invoking a constructor on a non-nominal type, the expression // is malformed. SourceRange initExprRange(fnExpr->getSourceRange().Start, argExpr->getSourceRange().End); CS.TC.diagnose(fnExpr->getLoc(), instTy->isExistentialType() ? diag::construct_protocol_by_name : diag::non_nominal_no_initializers, instTy) .highlight(initExprRange); return true; } } // Try to diagnose errors related to the use of implicit self reference. if (diagnoseImplicitSelfErrors(fnExpr, argExpr, CCI, argLabels, CS)) return true; if (diagnoseInstanceMethodAsCurriedMemberOnType(CCI, fnExpr, argExpr)) return true; // Do all the stuff that we only have implemented when there is a single // candidate. if (diagnoseSingleCandidateFailures(CCI, fnExpr, argExpr, argLabels)) return true; // If we have a failure where the candidate set differs on exactly one // argument, and where we have a consistent mismatch across the candidate set // (often because there is only one candidate in the set), then diagnose this // as a specific problem of passing something of the wrong type into a // parameter. // // We don't generally want to use this path to diagnose calls to // symmetrically-typed binary operators because it's likely that both // operands contributed to the type. if ((CCI.closeness == CC_OneArgumentMismatch || CCI.closeness == CC_OneArgumentNearMismatch || CCI.closeness == CC_OneGenericArgumentMismatch || CCI.closeness == CC_OneGenericArgumentNearMismatch || CCI.closeness == CC_GenericNonsubstitutableMismatch) && CCI.failedArgument.isValid() && !isSymmetricBinaryOperator(CCI)) { // Map the argument number into an argument expression. TCCOptions options = TCC_ForceRecheck; if (CCI.failedArgument.parameterType->is<InOutType>()) options |= TCC_AllowLValue; // It could be that the argument doesn't conform to an archetype. Expr *badArgExpr = getFailedArgumentExpr(CCI, argExpr); if (CCI.diagnoseGenericParameterErrors(badArgExpr)) return true; // Re-type-check the argument with the expected type of the candidate set. // This should produce a specific and tailored diagnostic saying that the // type mismatches with expectations. Type paramType = CCI.failedArgument.parameterType; if (!typeCheckChildIndependently(badArgExpr, paramType, CTP_CallArgument, options)) return true; } return false; } bool FailureDiagnosis::diagnoseSubscriptErrors(SubscriptExpr *SE, bool inAssignmentDestination) { auto baseExpr = typeCheckChildIndependently(SE->getBase()); if (!baseExpr) return true; auto baseType = CS.getType(baseExpr); if (isa<NilLiteralExpr>(baseExpr)) { diagnose(baseExpr->getLoc(), diag::cannot_subscript_nil_literal) .highlight(baseExpr->getSourceRange()); return true; } std::function<bool(ArrayRef<OverloadChoice>)> callback = [&](ArrayRef<OverloadChoice> candidates) -> bool { CalleeCandidateInfo calleeInfo(Type(), candidates, SE->hasTrailingClosure(), CS, /*selfAlreadyApplied*/ false); // We're about to typecheck the index list, which needs to be processed with // self already applied. for (unsigned i = 0, e = calleeInfo.size(); i != e; ++i) ++calleeInfo.candidates[i].level; auto indexExpr = typeCheckArgumentChildIndependently(SE->getIndex(), Type(), calleeInfo); if (!indexExpr) return true; // Back to analyzing the candidate list with self applied. for (unsigned i = 0, e = calleeInfo.size(); i != e; ++i) --calleeInfo.candidates[i].level; ArrayRef<Identifier> argLabels = SE->getArgumentLabels(); if (diagnoseParameterErrors(calleeInfo, SE, indexExpr, argLabels)) return true; auto indexType = CS.getType(indexExpr); auto decomposedBaseType = decomposeArgType(baseType, {Identifier()}); auto decomposedIndexType = decomposeArgType(indexType, argLabels); calleeInfo.filterList( [&](UncurriedCandidate cand) -> CalleeCandidateInfo::ClosenessResultTy { // Classify how close this match is. Non-subscript decls don't match. auto subscriptDecl = dyn_cast_or_null<SubscriptDecl>(cand.getDecl()); if (!subscriptDecl || (inAssignmentDestination && !subscriptDecl->isSettable())) return {CC_GeneralMismatch, {}}; // Check whether the self type matches. auto selfConstraint = CC_ExactMatch; if (calleeInfo.evaluateCloseness(cand, decomposedBaseType).first != CC_ExactMatch) selfConstraint = CC_SelfMismatch; // Increase the uncurry level to look past the self argument to the // indices. cand.level++; // Explode out multi-index subscripts to find the best match. auto indexResult = calleeInfo.evaluateCloseness(cand, decomposedIndexType); if (selfConstraint > indexResult.first) return {selfConstraint, {}}; return indexResult; }); // If the closest matches all mismatch on self, we either have something // that cannot be subscripted, or an ambiguity. if (calleeInfo.closeness == CC_SelfMismatch) { diagnose(SE->getLoc(), diag::cannot_subscript_base, baseType) .highlight(SE->getBase()->getSourceRange()); // FIXME: Should suggest overload set, but we're not ready for that until // it points to candidates and identifies the self type in the diagnostic. // calleeInfo.suggestPotentialOverloads(SE->getLoc()); return true; } // Any other failures relate to the index list. for (unsigned i = 0, e = calleeInfo.size(); i != e; ++i) ++calleeInfo.candidates[i].level; // TODO: Is there any reason to check for CC_NonLValueInOut here? if (calleeInfo.closeness == CC_ExactMatch) { auto message = diag::ambiguous_subscript; // If there is an exact match on the argument with // a single candidate, let's type-check subscript // as a whole to figure out if there is any structural // problem after all. if (calleeInfo.size() == 1) { Expr *expr = SE; ConcreteDeclRef decl = nullptr; message = diag::cannot_subscript_with_index; if (CS.TC.getTypeOfExpressionWithoutApplying(expr, CS.DC, decl)) return false; // If we are down to a single candidate but with an unresolved // index type, we can substitute in the base type to get a simpler // and more concrete expected type for this subscript decl, in order // to diagnose a better error. if (baseType && indexType->hasUnresolvedType()) { UncurriedCandidate cand = calleeInfo.candidates[0]; auto candType = baseType->getTypeOfMember(CS.DC->getParentModule(), cand.getDecl(), nullptr); if (auto *candFunc = candType->getAs<FunctionType>()) { auto paramsType = FunctionType::composeInput(CS.getASTContext(), candFunc->getParams(), false); if (!typeCheckChildIndependently( indexExpr, paramsType, CTP_CallArgument, TCC_ForceRecheck)) return true; } } } diagnose(SE->getLoc(), message, baseType, indexType) .highlight(indexExpr->getSourceRange()) .highlight(baseExpr->getSourceRange()); // FIXME: suggestPotentialOverloads should do this. // calleeInfo.suggestPotentialOverloads(SE->getLoc()); for (auto candidate : calleeInfo.candidates) if (auto decl = candidate.getDecl()) diagnose(decl, diag::found_candidate); else diagnose(candidate.getExpr()->getLoc(), diag::found_candidate); return true; } if (diagnoseParameterErrors(calleeInfo, SE, indexExpr, argLabels)) return true; // Diagnose some simple and common errors. if (calleeInfo.diagnoseSimpleErrors(SE)) return true; diagnose(SE->getLoc(), diag::cannot_subscript_with_index, baseType, indexType); calleeInfo.suggestPotentialOverloads(SE->getLoc()); return true; }; auto locator = CS.getConstraintLocator(SE, ConstraintLocator::SubscriptMember); return diagnoseMemberFailures(SE, baseExpr, ConstraintKind::ValueMember, DeclBaseName::createSubscript(), FunctionRefKind::DoubleApply, locator, callback); } bool FailureDiagnosis::visitSubscriptExpr(SubscriptExpr *SE) { return diagnoseSubscriptErrors(SE, /* inAssignmentDestination = */ false); } namespace { /// Type checking listener for pattern binding initializers. class CalleeListener : public ExprTypeCheckListener { Type contextualType; public: explicit CalleeListener(Type contextualType) : contextualType(contextualType) { } bool builtConstraints(ConstraintSystem &cs, Expr *expr) override { // If we have no contextual type, there is nothing to do. if (!contextualType) return false; // If the expression is obviously something that produces a metatype, // then don't put a constraint on it. auto semExpr = expr->getValueProvidingExpr(); if (isa<TypeExpr>(semExpr)) return false; auto resultLocator = cs.getConstraintLocator(expr, ConstraintLocator::FunctionResult); auto resultType = cs.createTypeVariable(resultLocator, TVO_CanBindToLValue); auto locator = cs.getConstraintLocator(expr); cs.addConstraint(ConstraintKind::FunctionResult, cs.getType(expr), resultType, locator); cs.addConstraint(ConstraintKind::Conversion, resultType, contextualType, locator); return false; } }; } // end anonymous namespace /// Return true if this function name is a comparison operator. This is a /// simple heuristic used to guide comparison related diagnostics. static bool isNameOfStandardComparisonOperator(StringRef opName) { return opName == "==" || opName == "!=" || opName == "===" || opName == "!==" || opName == "<" || opName == ">" || opName == "<=" || opName == ">="; } bool FailureDiagnosis::diagnoseNilLiteralComparison( Expr *lhsExpr, Expr *rhsExpr, CalleeCandidateInfo &calleeInfo, SourceLoc applyLoc) { auto overloadName = calleeInfo.declName; // Only diagnose for comparison operators. if (!isNameOfStandardComparisonOperator(overloadName)) return false; Expr *otherExpr = lhsExpr; Expr *nilExpr = rhsExpr; // Swap if we picked the wrong side as the nil literal. if (!isa<NilLiteralExpr>(nilExpr->getValueProvidingExpr())) std::swap(otherExpr, nilExpr); // Bail if neither side is a nil literal. if (!isa<NilLiteralExpr>(nilExpr->getValueProvidingExpr())) return false; // Bail if both sides are a nil literal. if (isa<NilLiteralExpr>(otherExpr->getValueProvidingExpr())) return false; auto otherType = CS.getType(otherExpr)->getRValueType(); // Bail if we were unable to determine the other type. if (isUnresolvedOrTypeVarType(otherType)) return false; // Regardless of whether the type has reference or value semantics, // comparison with nil is illegal, albeit for different reasons spelled // out by the diagnosis. if (otherType->getOptionalObjectType() && (overloadName == "!==" || overloadName == "===")) { auto revisedName = overloadName; revisedName.pop_back(); // If we made it here, then we're trying to perform a comparison with // reference semantics rather than value semantics. The fixit will // lop off the extra '=' in the operator. diagnose(applyLoc, diag::value_type_comparison_with_nil_illegal_did_you_mean, otherType) .fixItReplace(applyLoc, revisedName); } else { diagnose(applyLoc, diag::value_type_comparison_with_nil_illegal, otherType) .highlight(otherExpr->getSourceRange()); } return true; } bool FailureDiagnosis::diagnoseMethodAttributeFailures( swift::ApplyExpr *callExpr, ArrayRef<Identifier> argLabels, bool hasTrailingClosure, CalleeCandidateInfo &candidates) { auto UDE = dyn_cast<UnresolvedDotExpr>(callExpr->getFn()); if (!UDE) return false; auto argExpr = callExpr->getArg(); auto argType = CS.getType(argExpr); // If type of the argument hasn't been established yet, we can't diagnose. if (!argType || isUnresolvedOrTypeVarType(argType)) return false; // Let's filter our candidate list based on that type. candidates.filterListArgs(decomposeArgType(argType, argLabels)); if (candidates.closeness == CC_ExactMatch) return false; // And if filtering didn't give an exact match, such means that problem // might be related to function attributes which is best diagnosed by // unviable member candidates, if any. auto base = UDE->getBase(); auto baseType = CS.getType(base); // This handles following situation: // struct S { // mutating func f(_ i: Int) {} // func f(_ f: Float) {} // } // // Given struct has an overloaded method "f" with a single argument of // multiple different types, one of the overloads is marked as // "mutating", which means it can only be applied on LValue base type. // So when struct is used like this: // // let answer: Int = 42 // S().f(answer) // // Constraint system generator is going to pick `f(_ f: Float)` as // only possible overload candidate because "base" of the call is immutable // and contextual information about argument type is not available yet. // Such leads to incorrect contextual conversion failure diagnostic because // type of the argument is going to resolved as (Int) no matter what. // To workaround that fact and improve diagnostic of such cases we are going // to try and collect all unviable candidates for a given call and check if // at least one of them matches established argument type before even trying // to re-check argument expression. auto results = CS.performMemberLookup( ConstraintKind::ValueMember, UDE->getName(), baseType, UDE->getFunctionRefKind(), CS.getConstraintLocator(UDE), /*includeInaccessibleMembers=*/false); if (results.UnviableCandidates.empty()) return false; SmallVector<OverloadChoice, 2> choices; for (auto &unviable : results.UnviableCandidates) choices.push_back(OverloadChoice(baseType, unviable.first.getDecl(), UDE->getFunctionRefKind())); CalleeCandidateInfo unviableCandidates(baseType, choices, hasTrailingClosure, CS); // Filter list of the unviable candidates based on the // already established type of the argument expression. unviableCandidates.filterListArgs(decomposeArgType(argType, argLabels)); // If one of the unviable candidates matches arguments exactly, // that means that actual problem is related to function attributes. if (unviableCandidates.closeness == CC_ExactMatch) { diagnoseUnviableLookupResults(results, baseType, base, UDE->getName(), UDE->getNameLoc(), UDE->getLoc()); return true; } return false; } bool FailureDiagnosis::diagnoseArgumentGenericRequirements( TypeChecker &TC, Expr *callExpr, Expr *fnExpr, Expr *argExpr, CalleeCandidateInfo &candidates, ArrayRef<Identifier> argLabels) { if (candidates.closeness != CC_ExactMatch || candidates.size() != 1) return false; AbstractFunctionDecl *AFD = nullptr; if (auto *DRE = dyn_cast<DeclRefExpr>(fnExpr)) { AFD = dyn_cast<AbstractFunctionDecl>(DRE->getDecl()); } else if (auto *candidate = candidates[0].getDecl()) { AFD = dyn_cast<AbstractFunctionDecl>(candidate); } if (!AFD || !AFD->getGenericSignature() || !AFD->hasInterfaceType()) return false; auto env = AFD->getGenericEnvironment(); if (!env) return false; auto const &candidate = candidates.candidates[0]; if (!candidate.hasParameters()) return false; auto params = candidate.getParameters(); SmallBitVector defaultMap = computeDefaultMap(params, candidate.getDecl(), candidate.level); auto args = decomposeArgType(CS.getType(argExpr), argLabels); SmallVector<ParamBinding, 4> bindings; MatchCallArgumentListener listener; if (matchCallArguments(args, params, defaultMap, candidates.hasTrailingClosure, /*allowFixes=*/false, listener, bindings)) return false; TypeSubstitutionMap substitutions; // First, let's collect all of the archetypes and their substitutions, // that's going to help later on if there are cross-archetype // requirements e.g. <A, B where A.Element == B.Element>. for (unsigned i = 0, e = bindings.size(); i != e; ++i) { auto param = params[i]; auto paramType = param.getPlainType(); auto archetype = paramType->getAs<ArchetypeType>(); if (!archetype) continue; // Bindings specify the arguments that source the parameter. The only case // this returns a non-singular value is when there are varargs in play. for (auto argNo : bindings[i]) { auto argType = args[argNo] .getOldType() ->getWithoutSpecifierType(); if (auto *archetype = argType->getAs<ArchetypeType>()) { auto interfaceTy = archetype->getInterfaceType(); if (auto *paramTy = interfaceTy->getAs<GenericTypeParamType>()) { diagnoseAmbiguousGenericParameter(paramTy, fnExpr); return true; } } if (isUnresolvedOrTypeVarType(argType) || argType->hasError()) return false; // Record substitution from generic parameter to the argument type. substitutions[archetype->getInterfaceType()->getCanonicalType() ->castTo<SubstitutableType>()] = argType; } } if (substitutions.empty()) return false; class RequirementsListener : public GenericRequirementsCheckListener { ConstraintSystem &CS; AbstractFunctionDecl *Candidate; TypeSubstitutionFn Substitutions; Expr *CallExpr; Expr *FnExpr; Expr *ArgExpr; public: RequirementsListener(ConstraintSystem &cs, AbstractFunctionDecl *AFD, TypeSubstitutionFn subs, Expr *callExpr, Expr *fnExpr, Expr *argExpr) : CS(cs), Candidate(AFD), Substitutions(subs), CallExpr(callExpr), FnExpr(fnExpr), ArgExpr(argExpr) {} bool shouldCheck(RequirementKind kind, Type first, Type second) override { // This means that we have encountered requirement which references // generic parameter not used in the arguments, we can't diagnose it here. return !(first->hasTypeParameter() || first->isTypeVariableOrMember()); } bool diagnoseUnsatisfiedRequirement( const Requirement &req, Type first, Type second, ArrayRef<ParentConditionalConformance> parents) override { Diag<Type, Type, Type, Type, StringRef> note; switch (req.getKind()) { case RequirementKind::Conformance: case RequirementKind::Layout: return false; case RequirementKind::Superclass: note = diag::candidate_types_inheritance_requirement; break; case RequirementKind::SameType: note = diag::candidate_types_equal_requirement; break; } TypeChecker &TC = CS.TC; SmallVector<char, 8> scratch; auto overloadName = Candidate->getFullName().getString(scratch); if (isa<BinaryExpr>(CallExpr) && isa<TupleExpr>(ArgExpr)) { auto argTuple = cast<TupleExpr>(ArgExpr); auto lhsExpr = argTuple->getElement(0), rhsExpr = argTuple->getElement(1); auto lhsType = CS.getType(lhsExpr)->getRValueType(); auto rhsType = CS.getType(rhsExpr)->getRValueType(); TC.diagnose(FnExpr->getLoc(), diag::cannot_apply_binop_to_args, overloadName, lhsType, rhsType) .highlight(lhsExpr->getSourceRange()) .highlight(rhsExpr->getSourceRange()); } else if (isa<PrefixUnaryExpr>(CallExpr) || isa<PostfixUnaryExpr>(CallExpr)) { TC.diagnose(ArgExpr->getLoc(), diag::cannot_apply_unop_to_arg, overloadName, CS.getType(ArgExpr)); } else { bool isInitializer = isa<ConstructorDecl>(Candidate); TC.diagnose(ArgExpr->getLoc(), diag::cannot_call_with_params, overloadName, getTypeListString(CS.getType(ArgExpr)), isInitializer); } auto rawFirstType = req.getFirstType(); auto rawSecondType = req.getSecondType(); auto *genericSig = Candidate->getGenericSignature(); TC.diagnose(Candidate, note, first, second, rawFirstType, rawSecondType, TypeChecker::gatherGenericParamBindingsText( {rawFirstType, rawSecondType}, genericSig->getGenericParams(), Substitutions)); ParentConditionalConformance::diagnoseConformanceStack( TC.Diags, Candidate->getLoc(), parents); return true; } }; auto *dc = env->getOwningDeclContext(); auto substitutionFn = QueryTypeSubstitutionMap{substitutions}; RequirementsListener genericReqListener(CS, AFD, substitutionFn, callExpr, fnExpr, argExpr); auto result = TC.checkGenericArguments( dc, callExpr->getLoc(), fnExpr->getLoc(), AFD->getInterfaceType(), env->getGenericSignature()->getGenericParams(), env->getGenericSignature()->getRequirements(), substitutionFn, LookUpConformanceInModule{dc->getParentModule()}, ConformanceCheckFlags::SuppressDependencyTracking, &genericReqListener); // Note: If result is RequirementCheckResult::SubstitutionFailure, we did // not emit a diagnostic, so we must return false in that case. return result == RequirementCheckResult::Failure; } /// When initializing Unsafe[Mutable]Pointer<T> from Unsafe[Mutable]RawPointer, /// issue a diagnostic that refers to the API for binding memory to a type. static bool isCastToTypedPointer(ConstraintSystem &CS, const Expr *Fn, const Expr *Arg) { auto &Ctx = CS.DC->getASTContext(); auto *TypeExp = dyn_cast<TypeExpr>(Fn); auto *ParenExp = dyn_cast<ParenExpr>(Arg); if (!TypeExp || !ParenExp) return false; auto InitType = CS.getInstanceType(TypeExp); auto ArgType = CS.getType(ParenExp->getSubExpr()); if (InitType.isNull() || ArgType.isNull()) return false; // unwrap one level of Optional if (auto ArgOptType = ArgType->getOptionalObjectType()) ArgType = ArgOptType; auto *InitNom = InitType->getAnyNominal(); if (!InitNom) return false; if (InitNom != Ctx.getUnsafeMutablePointerDecl() && InitNom != Ctx.getUnsafePointerDecl()) { return false; } auto *ArgNom = ArgType->getAnyNominal(); if (!ArgNom) return false; if (ArgNom != Ctx.getUnsafeMutableRawPointerDecl() && ArgNom != Ctx.getUnsafeRawPointerDecl()) { return false; } return true; } static bool diagnoseClosureExplicitParameterMismatch( ConstraintSystem &CS, SourceLoc loc, ArrayRef<AnyFunctionType::Param> params, ArrayRef<AnyFunctionType::Param> args) { // We are not trying to diagnose structural problems with top-level // arguments here. if (params.size() != args.size()) return false; for (unsigned i = 0, n = params.size(); i != n; ++i) { auto paramType = params[i].getOldType(); auto argType = args[i].getOldType(); if (auto paramFnType = paramType->getAs<AnyFunctionType>()) { if (auto argFnType = argType->getAs<AnyFunctionType>()) return diagnoseClosureExplicitParameterMismatch( CS, loc, paramFnType->getParams(), argFnType->getParams()); } if (!paramType || !argType || isUnresolvedOrTypeVarType(paramType) || isUnresolvedOrTypeVarType(argType)) continue; if (!CS.TC.isConvertibleTo(argType, paramType, CS.DC)) { CS.TC.diagnose(loc, diag::types_not_convertible, false, paramType, argType); return true; } } return false; } bool FailureDiagnosis::diagnoseTrailingClosureErrors(ApplyExpr *callExpr) { if (!callExpr->hasTrailingClosure()) return false; auto *DC = CS.DC; auto *fnExpr = callExpr->getFn(); auto *argExpr = callExpr->getArg(); ClosureExpr *closureExpr = nullptr; if (auto *PE = dyn_cast<ParenExpr>(argExpr)) { closureExpr = dyn_cast<ClosureExpr>(PE->getSubExpr()); } else { return false; } if (!closureExpr) return false; class CallResultListener : public ExprTypeCheckListener { Type expectedResultType; public: explicit CallResultListener(Type resultType) : expectedResultType(resultType) {} bool builtConstraints(ConstraintSystem &cs, Expr *expr) override { if (!expectedResultType) return false; auto resultType = cs.getType(expr); auto *locator = cs.getConstraintLocator(expr); // Since we know that this is trailing closure, format of the // type could be like this - ((Input) -> Result) -> ClosureResult // which we can leverage to create specific conversion for // result type of the call itself, this might help us gain // some valuable contextual information. if (auto *fnType = resultType->getAs<AnyFunctionType>()) { cs.addConstraint(ConstraintKind::Conversion, fnType->getResult(), expectedResultType, locator); } else if (auto *typeVar = resultType->getAs<TypeVariableType>()) { auto tv = cs.createTypeVariable(cs.getConstraintLocator(expr), TVO_CanBindToLValue | TVO_PrefersSubtypeBinding); auto extInfo = FunctionType::ExtInfo().withThrows(); FunctionType::Param tvParam(tv); auto fTy = FunctionType::get({tvParam}, expectedResultType, extInfo); // Add a conversion constraint between the types. cs.addConstraint(ConstraintKind::Conversion, typeVar, fTy, locator, /*isFavored*/ true); } return false; } }; SmallPtrSet<TypeBase *, 4> possibleTypes; auto currentType = CS.getType(fnExpr); // If current type has type variables or unresolved types // let's try to re-typecheck it to see if we can get some // more information about what is going on. if (currentType->hasTypeVariable() || currentType->hasUnresolvedType()) { auto contextualType = CS.getContextualType(); CallResultListener listener(contextualType); CS.TC.getPossibleTypesOfExpressionWithoutApplying( fnExpr, CS.DC, possibleTypes, FreeTypeVariableBinding::UnresolvedType, &listener); // Looks like there is there a contextual mismatch // related to function type, let's try to diagnose it. if (possibleTypes.empty() && contextualType && !contextualType->hasUnresolvedType()) return diagnoseContextualConversionError(callExpr, contextualType, CS.getContextualTypePurpose()); } else { possibleTypes.insert(currentType.getPointer()); } for (Type type : possibleTypes) { auto *fnType = type->getAs<AnyFunctionType>(); if (!fnType) continue; auto params = fnType->getParams(); if (params.size() != 1) return false; Type paramType = params.front().getOldType(); if (auto paramFnType = paramType->getAs<AnyFunctionType>()) { auto closureType = CS.getType(closureExpr); if (auto *argFnType = closureType->getAs<AnyFunctionType>()) { auto *params = closureExpr->getParameters(); auto loc = params ? params->getStartLoc() : closureExpr->getStartLoc(); if (diagnoseClosureExplicitParameterMismatch( CS, loc, argFnType->getParams(), paramFnType->getParams())) return true; } } auto processor = [&](Type resultType, Type expectedResultType) -> bool { if (resultType && expectedResultType) { if (!resultType->isEqual(expectedResultType)) { CS.TC.diagnose(closureExpr->getEndLoc(), diag::cannot_convert_closure_result, resultType, expectedResultType); return true; } // Looks like both actual and expected result types match, // there is nothing we can diagnose in this case. return false; } // If we got a result type, let's re-typecheck the function using it, // maybe we can find a problem where contextually we expect one type // but trailing closure produces completely different one. auto fnType = paramType->getAs<AnyFunctionType>(); if (!fnType) return false; class ClosureCalleeListener : public ExprTypeCheckListener { FunctionType *InputType; Type ResultType; public: explicit ClosureCalleeListener(FunctionType *inputType, Type resultType) : InputType(inputType), ResultType(resultType) {} bool builtConstraints(ConstraintSystem &cs, Expr *expr) override { if (!ResultType) return false; AnyFunctionType::Param Input(InputType); auto expectedType = FunctionType::get({Input}, ResultType); cs.addConstraint(ConstraintKind::Conversion, cs.getType(expr), expectedType, cs.getConstraintLocator(expr), /*isFavored*/ true); return false; } }; auto expectedArgType = FunctionType::get(fnType->getParams(), resultType, fnType->getExtInfo()); llvm::SaveAndRestore<DeclContext *> SavedDC(CS.DC, DC); ClosureCalleeListener listener(expectedArgType, CS.getContextualType()); return !typeCheckChildIndependently(callExpr->getFn(), Type(), CTP_CalleeResult, TCC_ForceRecheck, &listener); }; // Let's see if there are any structural problems with closure itself. if (diagnoseClosureExpr(closureExpr, paramType, processor)) return true; } return false; } /// Check if there failure associated with expression is related /// to given contextual type. bool FailureDiagnosis::diagnoseCallContextualConversionErrors( ApplyExpr *callExpr, Type contextualType, ContextualTypePurpose CTP) { if (!contextualType || contextualType->hasUnresolvedType()) return false; auto &TC = CS.TC; auto *DC = CS.DC; auto typeCheckExpr = [](TypeChecker &TC, Expr *expr, DeclContext *DC, SmallPtrSetImpl<TypeBase *> &types) { TC.getPossibleTypesOfExpressionWithoutApplying( expr, DC, types, FreeTypeVariableBinding::Disallow); }; // First let's type-check expression without contextual type, and // see if that's going to produce a type, if so, let's type-check // again, this time using given contextual type. SmallPtrSet<TypeBase *, 4> withoutContextual; typeCheckExpr(TC, callExpr, DC, withoutContextual); // If there are no types returned, it means that problem was // nothing to do with contextual information, probably parameter/argument // mismatch. if (withoutContextual.empty()) return false; Type exprType = withoutContextual.size() == 1 ? *withoutContextual.begin() : Type(); return diagnoseContextualConversionError(callExpr, contextualType, CTP, exprType); } bool FailureDiagnosis::diagnoseSubscriptMisuse(ApplyExpr *callExpr) { auto UDE = dyn_cast<UnresolvedDotExpr>(callExpr->getFn()); if (!UDE) return false; auto baseExpr = UDE->getBase(); if (!baseExpr || UDE->getName().getBaseName() != getTokenText(tok::kw_subscript)) return false; auto baseType = CS.getType(baseExpr); // Look up subscript declarations. auto lookup = CS.lookupMember(baseType->getRValueType(), DeclName(DeclBaseName::createSubscript())); auto nonSubscrLookup = CS.lookupMember(baseType->getRValueType(), UDE->getName()); // Make sure we only found subscript declarations. If not, the problem // is different - return. if (lookup.empty() || !nonSubscrLookup.empty()) return false; // Try to resolve a type of the argument expression. auto argExpr = typeCheckChildIndependently(callExpr->getArg(), Type(), CTP_CallArgument); if (!argExpr) return CS.TC.Diags.hadAnyError(); SmallVector<Identifier, 2> scratch; ArrayRef<Identifier> argLabels = callExpr->getArgumentLabels(scratch); SmallVector<OverloadChoice, 2> choices; for (auto candidate : lookup) choices.push_back(OverloadChoice(baseType, candidate.getValueDecl(), UDE->getFunctionRefKind())); CalleeCandidateInfo candidateInfo(baseType, choices, callArgHasTrailingClosure(argExpr), CS, true); auto params = decomposeArgType(CS.getType(argExpr), argLabels); using ClosenessPair = CalleeCandidateInfo::ClosenessResultTy; candidateInfo.filterList([&](UncurriedCandidate cand) -> ClosenessPair { auto candFuncType = cand.getUncurriedFunctionType(); if (!candFuncType) return {CC_GeneralMismatch, {}}; auto candParams = candFuncType->getParams(); if (params.size() != candParams.size()) return {CC_GeneralMismatch, {}}; for (unsigned i = 0, e = params.size(); i < e; i ++) { if (CS.TC.isConvertibleTo(params[i].getOldType(), candParams[i].getOldType(), CS.DC) || candParams[i].getOldType()->is<GenericTypeParamType>()) continue; return {CC_GeneralMismatch, {}}; } return {CC_ExactMatch, {}}; }); auto *locator = CS.getConstraintLocator(UDE, ConstraintLocator::Member); auto memberRange = baseExpr->getSourceRange(); if (locator) locator = simplifyLocator(CS, locator, memberRange); auto nameLoc = DeclNameLoc(memberRange.Start); auto diag = diagnose(baseExpr->getLoc(), diag::could_not_find_subscript_member_did_you_mean, baseType); diag.highlight(memberRange).highlight(nameLoc.getSourceRange()); auto showNote = [&]() { diag.flush(); if (candidateInfo.size() == 1) diagnose(candidateInfo.candidates.front().getDecl(), diag::kind_declared_here, DescriptiveDeclKind::Subscript); }; if (candidateInfo.closeness != CC_ExactMatch) { showNote(); return true; } auto toCharSourceRange = Lexer::getCharSourceRangeFromSourceRange; auto lastArgSymbol = toCharSourceRange(CS.TC.Context.SourceMgr, argExpr->getEndLoc()); diag.fixItReplace(SourceRange(argExpr->getStartLoc()), getTokenText(tok::l_square)); diag.fixItRemove(nameLoc.getSourceRange()); diag.fixItRemove(SourceRange(UDE->getDotLoc())); if (CS.TC.Context.SourceMgr.extractText(lastArgSymbol) == getTokenText(tok::r_paren)) diag.fixItReplace(SourceRange(argExpr->getEndLoc()), getTokenText(tok::r_square)); else diag.fixItInsertAfter(argExpr->getEndLoc(), getTokenText(tok::r_square)); showNote(); return true; } // Check if there is a structural problem in the function expression // by performing type checking with the option to allow unresolved // type variables. If that is going to produce a function type with // unresolved result let's not re-typecheck the function expression, // because it might produce unrelated diagnostics due to lack of // contextual information. static bool shouldTypeCheckFunctionExpr(TypeChecker &TC, DeclContext *DC, Expr *fnExpr) { if (!isa<UnresolvedDotExpr>(fnExpr)) return true; SmallPtrSet<TypeBase *, 4> fnTypes; TC.getPossibleTypesOfExpressionWithoutApplying(fnExpr, DC, fnTypes, FreeTypeVariableBinding::UnresolvedType); if (fnTypes.size() == 1) { // Some member types depend on the arguments to produce a result type, // type-checking such expressions without associated arguments is // going to produce unrelated diagnostics. if (auto fn = (*fnTypes.begin())->getAs<AnyFunctionType>()) { auto resultType = fn->getResult(); if (resultType->hasUnresolvedType() || resultType->hasTypeVariable()) return false; } } // Might be a structural problem related to the member itself. return true; } // Check if any candidate of the overload set can accept a specified // number of arguments, regardless of parameter type or label information. static bool isViableOverloadSet(const CalleeCandidateInfo &CCI, size_t numArgs) { for (unsigned i = 0; i < CCI.size(); ++i) { auto &&cand = CCI[i]; auto funcDecl = dyn_cast_or_null<AbstractFunctionDecl>(cand.getDecl()); if (!funcDecl) continue; auto params = cand.getParameters(); bool hasVariadicParameter = false; auto pairMatcher = [&](unsigned argIdx, unsigned paramIdx) { hasVariadicParameter |= params[paramIdx].isVariadic(); return true; }; auto defaultMap = computeDefaultMap(params, funcDecl, cand.level); InputMatcher IM(params, defaultMap); auto result = IM.match(numArgs, pairMatcher); if (result == InputMatcher::IM_Succeeded) return true; if (result == InputMatcher::IM_HasUnclaimedInput && hasVariadicParameter) return true; } return false; } bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) { // If this call involves trailing closure as an argument, // let's treat it specially, because re-typecheck of the // either function or arguments might results in diagnosing // of the unrelated problems due to luck of context. if (diagnoseTrailingClosureErrors(callExpr)) return true; if (diagnoseCallContextualConversionErrors(callExpr, CS.getContextualType(), CS.getContextualTypePurpose())) return true; auto *fnExpr = callExpr->getFn(); auto originalFnType = CS.getType(callExpr->getFn()); if (shouldTypeCheckFunctionExpr(CS.TC, CS.DC, fnExpr)) { // If we are misusing a subscript, diagnose that and provide a fixit. // We diagnose this here to have enough context to offer an appropriate fixit. if (diagnoseSubscriptMisuse(callExpr)) { return CS.TC.Diags.hadAnyError(); } // Type check the function subexpression to resolve a type for it if // possible. fnExpr = typeCheckChildIndependently(callExpr->getFn()); if (!fnExpr) { return CS.TC.Diags.hadAnyError(); } } SWIFT_DEFER { if (!fnExpr) return; // If it's a member operator reference, put the operator back. if (auto operatorRef = fnExpr->getMemberOperatorRef()) callExpr->setFn(operatorRef); }; auto getFuncType = [](Type type) -> Type { return type->getRValueType(); }; auto fnType = getFuncType(CS.getType(fnExpr)); // Let's see if this has to do with member vs. property error // because sometimes when there is a member and a property declared // on the nominal type with the same name. Type-checking function // expression separately from arguments might produce solution for // the property instead of the member. if (!fnType->is<AnyFunctionType>() && isa<UnresolvedDotExpr>(callExpr->getFn())) { fnExpr = callExpr->getFn(); SmallPtrSet<TypeBase *, 4> types; CS.TC.getPossibleTypesOfExpressionWithoutApplying(fnExpr, CS.DC, types); auto isFunctionType = [getFuncType](Type type) -> bool { return type && getFuncType(type)->is<AnyFunctionType>(); }; auto fnTypes = std::find_if(types.begin(), types.end(), isFunctionType); if (fnTypes != types.end()) { auto funcType = getFuncType(*fnTypes); // If there is only one function type, let's use it. if (std::none_of(std::next(fnTypes), types.end(), isFunctionType)) fnType = funcType; } else { fnType = getFuncType(originalFnType); } } // If we have a contextual type, and if we have an ambiguously typed function // result from our previous check, we re-type-check it using this contextual // type to inform the result type of the callee. // // We only do this as a second pass because the first pass we just did may // return something of obviously non-function-type. If this happens, we // produce better diagnostics below by diagnosing this here rather than trying // to peel apart the failed conversion to function type. if (CS.getContextualType() && (isUnresolvedOrTypeVarType(fnType) || (fnType->is<AnyFunctionType>() && fnType->hasUnresolvedType()))) { // FIXME: Prevent typeCheckChildIndependently from transforming expressions, // because if we try to typecheck OSR expression with contextual type, // it'll end up converting it into DeclRefExpr based on contextual info, // instead let's try to get a type without applying and filter callee // candidates later on. CalleeListener listener(CS.getContextualType()); if (isa<OverloadSetRefExpr>(fnExpr)) { assert(!cast<OverloadSetRefExpr>(fnExpr)->getReferencedDecl() && "unexpected declaration reference"); ConcreteDeclRef decl = nullptr; Type type = CS.TC.getTypeOfExpressionWithoutApplying( fnExpr, CS.DC, decl, FreeTypeVariableBinding::UnresolvedType, &listener); if (type) fnType = getFuncType(type); } else { fnExpr = typeCheckChildIndependently(callExpr->getFn(), Type(), CTP_CalleeResult, TCC_ForceRecheck, &listener); if (!fnExpr) return true; fnType = getFuncType(CS.getType(fnExpr)); } } // If we resolved a concrete expression for the callee, and it has // non-function/non-metatype type, then we cannot call it! if (!isUnresolvedOrTypeVarType(fnType) && !fnType->is<AnyFunctionType>() && !fnType->is<MetatypeType>() // SWIFT_ENABLE_TENSORFLOW && !CS.DynamicCallableCache[fnType->getCanonicalType()].isValid()) { auto arg = callExpr->getArg(); if (fnType->is<ExistentialMetatypeType>()) { auto diag = diagnose(arg->getStartLoc(), diag::missing_init_on_metatype_initialization); diag.highlight(fnExpr->getSourceRange()); } else { auto diag = diagnose(arg->getStartLoc(), diag::cannot_call_non_function_value, fnType); diag.highlight(fnExpr->getSourceRange()); // If the argument is an empty tuple, then offer a // fix-it to remove the empty tuple and use the value // directly. if (auto tuple = dyn_cast<TupleExpr>(arg)) { if (tuple->getNumElements() == 0) { diag.fixItRemove(arg->getSourceRange()); } } } // If the argument is a trailing ClosureExpr (i.e. {....}) and it is on // the line after the callee, then it's likely the user forgot to // write "do" before their brace stmt. // Note that line differences of more than 1 are diagnosed during parsing. if (auto *PE = dyn_cast<ParenExpr>(arg)) if (PE->hasTrailingClosure() && isa<ClosureExpr>(PE->getSubExpr())) { auto *closure = cast<ClosureExpr>(PE->getSubExpr()); auto &SM = CS.getASTContext().SourceMgr; if (closure->hasAnonymousClosureVars() && closure->getParameters()->size() == 0 && 1 + SM.getLineNumber(callExpr->getFn()->getEndLoc()) == SM.getLineNumber(closure->getStartLoc())) { diagnose(closure->getStartLoc(), diag::brace_stmt_suggest_do) .fixItInsert(closure->getStartLoc(), "do "); } } return true; } bool hasTrailingClosure = callArgHasTrailingClosure(callExpr->getArg()); // Collect a full candidate list of callees based on the partially type // checked function. CalleeCandidateInfo calleeInfo(fnExpr, hasTrailingClosure, CS); // In the case that function subexpression was resolved independently in // the first place, the resolved type may not provide the best diagnostic. // We consider the number of arguments to decide whether we'd go with it or // stay with the original one. if (fnExpr != callExpr->getFn()) { bool isInstanceMethodAsCurriedMemberOnType = false; if (!calleeInfo.empty()) { auto &&cand = calleeInfo[0]; auto decl = cand.getDecl(); if (decl && decl->isInstanceMember() && cand.level == 0 && cand.getParameters().size() == 1) isInstanceMethodAsCurriedMemberOnType = true; } // In terms of instance method as curried member on type, we should not // take the number of arguments into account. if (!isInstanceMethodAsCurriedMemberOnType) { size_t numArgs = 1; auto arg = callExpr->getArg(); if (auto tuple = dyn_cast<TupleExpr>(arg)) { numArgs = tuple->getNumElements(); } if (!isViableOverloadSet(calleeInfo, numArgs)) { CalleeCandidateInfo calleeInfoOrig(callExpr->getFn(), hasTrailingClosure, CS); if (isViableOverloadSet(calleeInfoOrig, numArgs)) { fnExpr = callExpr->getFn(); fnType = getFuncType(CS.getType(fnExpr)); calleeInfo = calleeInfoOrig; } } } } // Filter list of the candidates based on the known function type. if (auto fn = fnType->getAs<AnyFunctionType>()) { using Closeness = CalleeCandidateInfo::ClosenessResultTy; calleeInfo.filterList([&](UncurriedCandidate candidate) -> Closeness { auto resultType = candidate.getResultType(); if (!resultType) return {CC_GeneralMismatch, {}}; // FIXME: Handle matching of the generic types properly. // Currently we don't filter result types containing generic parameters // because there is no easy way to do that, and candidate set is going // to be pruned by matching of the argument types later on anyway, so // it's better to over report than to be too conservative. if (resultType->isEqual(fn->getResult())) return {CC_ExactMatch, {}}; return {CC_GeneralMismatch, {}}; }); } // Filter the candidate list based on the argument we may or may not have. calleeInfo.filterContextualMemberList(callExpr->getArg()); SmallVector<Identifier, 2> argLabelsScratch; ArrayRef<Identifier> argLabels = callExpr->getArgumentLabels(argLabelsScratch); if (diagnoseParameterErrors(calleeInfo, callExpr->getFn(), callExpr->getArg(), argLabels)) return true; // There might be a candidate with correct argument types but it's not // used by constraint solver because it doesn't have correct attributes, // let's try to diagnose such situation there right before type checking // argument expression, because that would overwrite original argument types. if (diagnoseMethodAttributeFailures(callExpr, argLabels, hasTrailingClosure, calleeInfo)) return true; Type argType; // argument list, if known. if (auto FTy = fnType->getAs<AnyFunctionType>()) { argType = FunctionType::composeInput(CS.getASTContext(), FTy->getParams(), false); } else if (auto MTT = fnType->getAs<AnyMetatypeType>()) { // If we are constructing a tuple with initializer syntax, the expected // argument list is the tuple type itself - and there is no initdecl. auto instanceTy = MTT->getInstanceType(); if (auto tupleTy = instanceTy->getAs<TupleType>()) { argType = tupleTy; } } // If there is a failing constraint associated with current constraint // system which points to the argument/parameter mismatch, let's use // that information while re-typechecking argument expression, this // makes it a lot easier to determine contextual mismatch. if (CS.failedConstraint && !hasTrailingClosure) { auto *constraint = CS.failedConstraint; if (constraint->getKind() == ConstraintKind::ApplicableFunction) { if (auto *locator = constraint->getLocator()) { if (locator->getAnchor() == callExpr) { auto calleeType = CS.simplifyType(constraint->getSecondType()); if (auto *fnType = calleeType->getAs<FunctionType>()) argType = AnyFunctionType::composeInput(fnType->getASTContext(), fnType->getParams(), /*canonicalVararg=*/false); } } } } // Get the expression result of type checking the arguments to the call // independently, so we have some idea of what we're working with. // auto argExpr = typeCheckArgumentChildIndependently(callExpr->getArg(), argType, calleeInfo, TCC_AllowUnresolvedTypeVariables); if (!argExpr) return true; // already diagnosed. calleeInfo.filterListArgs(decomposeArgType(CS.getType(argExpr), argLabels)); if (diagnoseParameterErrors(calleeInfo, callExpr->getFn(), argExpr, argLabels)) return true; // Diagnose some simple and common errors. if (calleeInfo.diagnoseSimpleErrors(callExpr)) return true; // Force recheck of the arg expression because we allowed unresolved types // before, and that turned out not to help, and now we want any diagnoses // from disallowing them. argExpr = typeCheckArgumentChildIndependently(callExpr->getArg(), argType, calleeInfo, TCC_ForceRecheck); if (!argExpr) return true; // already diagnosed. // Handle argument label mismatches when we have multiple candidates. if (calleeInfo.closeness == CC_ArgumentLabelMismatch) { auto args = decomposeArgType(CS.getType(argExpr), argLabels); // If we have multiple candidates that we fail to match, just say we have // the wrong labels and list the candidates out. // TODO: It would be nice to use an analog of getTypeListString that // doesn't include the argument types. diagnose(callExpr->getLoc(), diag::wrong_argument_labels_overload, getParamListAsString(args)) .highlight(argExpr->getSourceRange()); // Did the user intend on invoking a different overload? calleeInfo.suggestPotentialOverloads(fnExpr->getLoc()); return true; } auto overloadName = calleeInfo.declName; // Local function to check if the error with argument type is // related to contextual type information of the enclosing expression // rather than resolution of argument expression itself. auto isContextualConversionFailure = [&](Expr *argExpr) -> bool { // If we found an exact match, this must be a problem with a conversion from // the result of the call to the expected type. Diagnose this as a // conversion failure. if (calleeInfo.closeness == CC_ExactMatch) return true; if (!CS.getContextualType() || (calleeInfo.closeness != CC_ArgumentMismatch && calleeInfo.closeness != CC_OneGenericArgumentMismatch)) return false; CalleeCandidateInfo candidates(fnExpr, hasTrailingClosure, CS); // Filter original list of choices based on the deduced type of // argument expression after force re-check. candidates.filterContextualMemberList(argExpr); // One of the candidates matches exactly, which means that // this is a contextual type conversion failure, we can't diagnose here. return candidates.closeness == CC_ExactMatch; }; // Otherwise, we have a generic failure. Diagnose it with a generic error // message now. if (isa<BinaryExpr>(callExpr) && isa<TupleExpr>(argExpr)) { auto argTuple = cast<TupleExpr>(argExpr); auto lhsExpr = argTuple->getElement(0), rhsExpr = argTuple->getElement(1); auto lhsType = CS.getType(lhsExpr)->getRValueType(); auto rhsType = CS.getType(rhsExpr)->getRValueType(); // Diagnose any comparisons with the nil literal. if (diagnoseNilLiteralComparison(lhsExpr, rhsExpr, calleeInfo, callExpr->getLoc())) return true; if (callExpr->isImplicit() && overloadName == "~=") { // This binop was synthesized when typechecking an expression pattern. auto diag = lhsType->is<UnresolvedType>() ? diagnose(lhsExpr->getLoc(), diag::cannot_match_unresolved_expr_pattern_with_value, rhsType) : diagnose(lhsExpr->getLoc(), diag::cannot_match_expr_pattern_with_value, lhsType, rhsType); diag.highlight(lhsExpr->getSourceRange()); diag.highlight(rhsExpr->getSourceRange()); if (auto optUnwrappedType = rhsType->getOptionalObjectType()) { if (lhsType->isEqual(optUnwrappedType)) { diag.fixItInsertAfter(lhsExpr->getEndLoc(), "?"); } } return true; } // Diagnose attempts to compare reference equality of certain types. if (overloadName == "===" || overloadName == "!==") { // Functions. if (lhsType->is<AnyFunctionType>() || rhsType->is<AnyFunctionType>()) { diagnose(callExpr->getLoc(), diag::cannot_reference_compare_types, overloadName, lhsType, rhsType) .highlight(lhsExpr->getSourceRange()) .highlight(rhsExpr->getSourceRange()); return true; } } if (diagnoseArgumentGenericRequirements(CS.TC, callExpr, fnExpr, argExpr, calleeInfo, argLabels)) return true; if (isContextualConversionFailure(argTuple)) return false; if (diagnoseRawRepresentableMismatch(calleeInfo, argExpr, argLabels)) return true; if (!lhsType->isEqual(rhsType)) { auto diag = diagnose(callExpr->getLoc(), diag::cannot_apply_binop_to_args, overloadName, lhsType, rhsType); diag.highlight(lhsExpr->getSourceRange()) .highlight(rhsExpr->getSourceRange()); auto tryFixIts = [&]() -> bool { if (calleeInfo.size() != 1) return false; auto candidate = calleeInfo[0]; auto *fnType = candidate.getUncurriedFunctionType(); if (!fnType) return false; auto params = fnType->getParams(); if (params.size() != 2) return false; auto lhsCandidate = params[0].getOldType(); auto rhsCandidate = params[1].getOldType(); auto lhsIsCandidate = lhsType->isEqual(lhsCandidate); auto rhsIsCandidate = rhsType->isEqual(rhsCandidate); if (!lhsIsCandidate && !rhsIsCandidate) return false; if (!lhsIsCandidate) return tryIntegerCastFixIts(diag, CS, lhsType, lhsCandidate, lhsExpr); if (!rhsIsCandidate) return tryIntegerCastFixIts(diag, CS, rhsType, rhsCandidate, rhsExpr); return false; }; tryFixIts(); } else { diagnose(callExpr->getLoc(), diag::cannot_apply_binop_to_same_args, overloadName, lhsType) .highlight(lhsExpr->getSourceRange()) .highlight(rhsExpr->getSourceRange()); } if (lhsType->isEqual(rhsType) && isNameOfStandardComparisonOperator(overloadName) && lhsType->is<EnumType>() && !lhsType->getAs<EnumType>()->getDecl() ->hasOnlyCasesWithoutAssociatedValues()) { diagnose(callExpr->getLoc(), diag::no_binary_op_overload_for_enum_with_payload, overloadName); } else { calleeInfo.suggestPotentialOverloads(callExpr->getLoc()); } return true; } // If all of the arguments are a perfect match, let's check if there // are problems with requirements placed on generic parameters, because // CalleeCandidateInfo validates only conformance of the parameters // to their protocol types (if any) but it doesn't check additional // requirements placed on e.g. nested types or between parameters. if (diagnoseArgumentGenericRequirements(CS.TC, callExpr, fnExpr, argExpr, calleeInfo, argLabels)) return true; // If we have a failure where closeness is an exact match, but there is // still a failed argument, it is because one (or more) of the arguments // types are unresolved. if (calleeInfo.closeness == CC_ExactMatch && calleeInfo.failedArgument.isValid()) { diagnoseAmbiguity(getFailedArgumentExpr(calleeInfo, argExpr)); return true; } if (isContextualConversionFailure(argExpr)) return false; // Generate specific error messages for unary operators. if (isa<PrefixUnaryExpr>(callExpr) || isa<PostfixUnaryExpr>(callExpr)) { assert(!overloadName.empty()); diagnose(argExpr->getLoc(), diag::cannot_apply_unop_to_arg, overloadName, CS.getType(argExpr)); calleeInfo.suggestPotentialOverloads(argExpr->getLoc()); return true; } if (CS.getType(argExpr)->hasUnresolvedType()) return false; if (diagnoseRawRepresentableMismatch(calleeInfo, argExpr, argLabels)) return true; std::string argString = getTypeListString(CS.getType(argExpr)); // If we couldn't get the name of the callee, then it must be something of a // more complex "value of function type". if (overloadName.empty()) { // If we couldn't infer the result type of the closure expr, then we have // some sort of ambiguity, let the ambiguity diagnostic stuff handle this. if (auto ffty = fnType->getAs<AnyFunctionType>()) if (ffty->getResult()->hasTypeVariable()) { diagnoseAmbiguity(fnExpr); return true; } // The most common unnamed value of closure type is a ClosureExpr, so // special case it. if (isa<ClosureExpr>(fnExpr->getValueProvidingExpr())) { if (fnType->hasTypeVariable()) diagnose(argExpr->getStartLoc(), diag::cannot_invoke_closure, argString) .highlight(fnExpr->getSourceRange()); else diagnose(argExpr->getStartLoc(), diag::cannot_invoke_closure_type, fnType, argString) .highlight(fnExpr->getSourceRange()); } else if (fnType->hasTypeVariable()) { diagnose(argExpr->getStartLoc(), diag::cannot_call_function_value, argString) .highlight(fnExpr->getSourceRange()); } else { diagnose(argExpr->getStartLoc(), diag::cannot_call_value_of_function_type, fnType, argString) .highlight(fnExpr->getSourceRange()); } return true; } if (auto MTT = fnType->getAs<MetatypeType>()) { if (MTT->getInstanceType()->isExistentialType()) { diagnose(fnExpr->getLoc(), diag::construct_protocol_value, fnType); return true; } } // If we have an argument list (i.e., a scalar, or a non-zero-element tuple) // then diagnose with some specificity about the arguments. bool isInitializer = isa<TypeExpr>(fnExpr); if (isa<TupleExpr>(argExpr) && cast<TupleExpr>(argExpr)->getNumElements() == 0) { // Emit diagnostics that say "no arguments". diagnose(fnExpr->getLoc(), diag::cannot_call_with_no_params, overloadName, isInitializer); } else { diagnose(fnExpr->getLoc(), diag::cannot_call_with_params, overloadName, argString, isInitializer); } if (isCastToTypedPointer(CS, fnExpr, argExpr)) { diagnose(fnExpr->getLoc(), diag::pointer_init_to_type) .highlight(argExpr->getSourceRange()); } // Did the user intend on invoking a different overload? calleeInfo.suggestPotentialOverloads(fnExpr->getLoc()); return true; } bool FailureDiagnosis::visitAssignExpr(AssignExpr *assignExpr) { // Diagnose obvious assignments to literals. if (isa<LiteralExpr>(assignExpr->getDest()->getValueProvidingExpr())) { diagnose(assignExpr->getLoc(), diag::cannot_assign_to_literal); return true; } if (CS.TC.diagnoseSelfAssignment(assignExpr)) return true; // Type check the destination first, so we can coerce the source to it. auto destExpr = typeCheckChildIndependently(assignExpr->getDest(), TCC_AllowLValue); if (!destExpr) return true; auto destType = CS.getType(destExpr); if (destType->is<UnresolvedType>() || destType->hasTypeVariable()) { // Look closer into why destination has unresolved types since such // means that destination has diagnosable structural problems, and it's // better to diagnose destination (if possible) before moving on to // the source of the assignment. destExpr = typeCheckChildIndependently( destExpr, TCC_AllowLValue | TCC_ForceRecheck, false); if (!destExpr) return true; // If re-checking destination didn't produce diagnostic, let's just type // check the source without contextual information. If it succeeds, then we // win, but if it fails, we'll have to diagnose this another way. return !typeCheckChildIndependently(assignExpr->getSrc()); } // If the result type is a non-lvalue, then we are failing because it is // immutable and that's not a great thing to assign to. if (!destType->hasLValueType()) { // If the destination is a subscript, the problem may actually be that we // incorrectly decided on a get-only subscript overload, and we may be able // to come up with a better diagnosis by looking only at subscript candidates // that are set-able. if (auto subscriptExpr = dyn_cast<SubscriptExpr>(destExpr)) { if (diagnoseSubscriptErrors(subscriptExpr, /* inAssignmentDestination = */ true)) return true; } // Member ref assignment errors detected elsewhere, so not an assignment issue if found here. // The remaining exception involves mutable pointer conversions which aren't always caught elsewhere. PointerTypeKind ptk; if (!isa<MemberRefExpr>(destExpr) || CS.getType(destExpr) ->lookThroughAllOptionalTypes() ->getAnyPointerElementType(ptk)) { AssignmentFailure failure(destExpr, CS, assignExpr->getLoc()); if (failure.diagnoseAsError()) return true; } } auto *srcExpr = assignExpr->getSrc(); auto contextualType = destType->getRValueType(); // Let's try to type-check assignment source expression without using // destination as a contextual type, that allows us to diagnose // contextual problems related to source much easier. // // If source expression requires contextual type to be present, // let's avoid this step because it's always going to fail. { auto *srcExpr = assignExpr->getSrc(); ExprTypeSaverAndEraser eraser(srcExpr); ConcreteDeclRef ref = nullptr; auto type = CS.TC.getTypeOfExpressionWithoutApplying(srcExpr, CS.DC, ref); if (type && !type->isEqual(contextualType)) return diagnoseContextualConversionError( assignExpr->getSrc(), contextualType, CTP_AssignSource); } srcExpr = typeCheckChildIndependently(assignExpr->getSrc(), contextualType, CTP_AssignSource); if (!srcExpr) return true; // If we are assigning to _ and have unresolved types on the RHS, then we have // an ambiguity problem. if (isa<DiscardAssignmentExpr>(destExpr->getSemanticsProvidingExpr()) && CS.getType(srcExpr)->hasUnresolvedType()) { diagnoseAmbiguity(srcExpr); return true; } return false; } /// Return true if this type is known to be an ArrayType. static bool isKnownToBeArrayType(Type ty) { if (!ty) return false; auto bgt = ty->getAs<BoundGenericType>(); if (!bgt) return false; auto &ctx = bgt->getASTContext(); return bgt->getDecl() == ctx.getArrayDecl(); } bool FailureDiagnosis::visitInOutExpr(InOutExpr *IOE) { // If we have a contextual type, it must be an inout type. auto contextualType = CS.getContextualType(); if (contextualType) { // If the contextual type is one of the UnsafePointer<T> types, then the // contextual type of the subexpression must be T. Type unwrappedType = contextualType; if (auto unwrapped = contextualType->getOptionalObjectType()) unwrappedType = unwrapped; if (auto pointerEltType = unwrappedType->getAnyPointerElementType()) { // If the element type is Void, then we allow any input type, since // everything is convertible to UnsafeRawPointer if (pointerEltType->isVoid()) contextualType = Type(); else contextualType = pointerEltType; // Furthermore, if the subexpr type is already known to be an array type, // then we must have an attempt at an array to pointer conversion. if (isKnownToBeArrayType(CS.getType(IOE->getSubExpr()))) { contextualType = ArraySliceType::get(contextualType); } } else if (contextualType->is<InOutType>()) { contextualType = contextualType->getInOutObjectType(); } else { // If the caller expected something inout, but we didn't have // something of inout type, diagnose it. diagnose(IOE->getLoc(), diag::extra_address_of, contextualType) .highlight(IOE->getSourceRange()) .fixItRemove(IOE->getStartLoc()); return true; } } if (!typeCheckChildIndependently(IOE->getSubExpr(), contextualType, CS.getContextualTypePurpose(), TCC_AllowLValue)) { return true; } return false; } bool FailureDiagnosis::visitCoerceExpr(CoerceExpr *CE) { // Coerce the input to whatever type is specified by the CoerceExpr. auto expr = typeCheckChildIndependently(CE->getSubExpr(), CS.getType(CE->getCastTypeLoc()), CTP_CoerceOperand); if (!expr) return true; auto ref = expr->getReferencedDecl(); if (auto *decl = ref.getDecl()) { // Without explicit coercion we might end up // type-checking sub-expression as unavaible // declaration, let's try to diagnose that here. if (AvailableAttr::isUnavailable(decl)) return diagnoseExplicitUnavailability( decl, expr->getSourceRange(), CS.DC, dyn_cast<ApplyExpr>(expr)); } return false; } bool FailureDiagnosis::visitForceValueExpr(ForceValueExpr *FVE) { auto argExpr = typeCheckChildIndependently(FVE->getSubExpr()); if (!argExpr) return true; auto argType = CS.getType(argExpr); // If the subexpression type checks as a non-optional type, then that is the // error. Produce a specific diagnostic about this. if (!isUnresolvedOrTypeVarType(argType) && argType->getOptionalObjectType().isNull()) { diagnose(FVE->getLoc(), diag::invalid_force_unwrap, argType) .fixItRemove(FVE->getExclaimLoc()) .highlight(FVE->getSourceRange()); return true; } return false; } bool FailureDiagnosis::visitBindOptionalExpr(BindOptionalExpr *BOE) { auto argExpr = typeCheckChildIndependently(BOE->getSubExpr()); if (!argExpr) return true; auto argType = CS.getType(argExpr); // If the subexpression type checks as a non-optional type, then that is the // error. Produce a specific diagnostic about this. if (!isUnresolvedOrTypeVarType(argType) && argType->getOptionalObjectType().isNull()) { diagnose(BOE->getQuestionLoc(), diag::invalid_optional_chain, argType) .highlight(BOE->getSourceRange()) .fixItRemove(BOE->getQuestionLoc()); return true; } return false; } bool FailureDiagnosis::visitIfExpr(IfExpr *IE) { auto typeCheckClauseExpr = [&](Expr *clause, Type contextType = Type(), ContextualTypePurpose convertPurpose = CTP_Unused) -> Expr * { // Provide proper contextual type when type conversion is specified. return typeCheckChildIndependently(clause, contextType, convertPurpose, TCCOptions(), nullptr, false); }; // Check all of the subexpressions independently. auto condExpr = typeCheckClauseExpr(IE->getCondExpr()); if (!condExpr) return true; auto trueExpr = typeCheckClauseExpr(IE->getThenExpr(), CS.getContextualType(), CS.getContextualTypePurpose()); if (!trueExpr) return true; auto falseExpr = typeCheckClauseExpr( IE->getElseExpr(), CS.getContextualType(), CS.getContextualTypePurpose()); if (!falseExpr) return true; // If the true/false values already match, it must be a contextual problem. if (CS.getType(trueExpr)->isEqual(CS.getType(falseExpr))) return false; // Otherwise, the true/false result types must not be matching. diagnose(IE->getColonLoc(), diag::if_expr_cases_mismatch, CS.getType(trueExpr), CS.getType(falseExpr)) .highlight(trueExpr->getSourceRange()) .highlight(falseExpr->getSourceRange()); return true; } bool FailureDiagnosis:: visitRebindSelfInConstructorExpr(RebindSelfInConstructorExpr *E) { // Don't walk the children for this node, it leads to multiple diagnostics // because of how sema injects this node into the type checker. return false; } bool FailureDiagnosis::visitCaptureListExpr(CaptureListExpr *CLE) { // Always walk into the closure of a capture list expression. return visitClosureExpr(CLE->getClosureBody()); } static bool isInvalidClosureResultType(Type resultType) { return !resultType || resultType->hasUnresolvedType() || resultType->hasTypeVariable() || resultType->hasArchetype(); } bool FailureDiagnosis::visitClosureExpr(ClosureExpr *CE) { return diagnoseClosureExpr( CE, CS.getContextualType(), [&](Type resultType, Type expectedResultType) -> bool { if (isInvalidClosureResultType(expectedResultType)) return false; // Following situations are possible: // * No result type - possible structurable problem in the body; // * Function result type - possible use of function without calling it, // which is properly diagnosed by actual type-check call. if (resultType && !resultType->getRValueType()->is<AnyFunctionType>()) { if (!resultType->isEqual(expectedResultType)) { diagnose(CE->getEndLoc(), diag::cannot_convert_closure_result, resultType, expectedResultType); return true; } } return false; }); } bool FailureDiagnosis::diagnoseClosureExpr( ClosureExpr *CE, Type contextualType, llvm::function_ref<bool(Type, Type)> resultTypeProcessor) { // Look through IUO because it doesn't influence // neither parameter nor return type diagnostics itself, // but if we have function type inside, that might // signficantly improve diagnostic quality. // FIXME: We need to rework this with IUOs out of the type system. // if (contextualType) { // if (auto IUO = // CS.lookThroughImplicitlyUnwrappedOptionalType(contextualType)) // contextualType = IUO; // } Type expectedResultType; // If we have a contextual type available for this closure, apply it to the // ParamDecls in our parameter list. This ensures that any uses of them get // appropriate types. if (contextualType && contextualType->is<AnyFunctionType>()) { auto fnType = contextualType->getAs<AnyFunctionType>(); auto *params = CE->getParameters(); auto inferredArgs = fnType->getParams(); // It is very common for a contextual type to disagree with the argument // list built into the closure expr. This can be because the closure expr // had an explicitly specified pattern, a la: // { a,b in ... } // or could be because the closure has an implicitly generated one: // { $0 + $1 } // in either case, we want to produce nice and clear diagnostics. unsigned actualArgCount = params->size(); unsigned inferredArgCount = inferredArgs.size(); if (actualArgCount != inferredArgCount) { // If the closure didn't specify any arguments and it is in a context that // needs some, produce a fixit to turn "{...}" into "{ _,_ in ...}". if (actualArgCount == 0 && CE->getInLoc().isInvalid()) { auto diag = diagnose(CE->getStartLoc(), diag::closure_argument_list_missing, inferredArgCount); std::string fixText; // Let's provide fixits for up to 10 args. if (inferredArgCount <= 10) { fixText += " _"; for (unsigned i = 0; i < inferredArgCount - 1; i ++) { fixText += ",_"; } fixText += " in "; } if (!fixText.empty()) { // Determine if there is already a space after the { in the closure to // make sure we introduce the right whitespace. auto afterBrace = CE->getStartLoc().getAdvancedLoc(1); auto text = CS.TC.Context.SourceMgr.extractText({afterBrace, 1}); if (text.size() == 1 && text == " ") fixText = fixText.erase(fixText.size() - 1); else fixText = fixText.erase(0, 1); diag.fixItInsertAfter(CE->getStartLoc(), fixText); } return true; } if (inferredArgCount == 1 && actualArgCount > 1) { auto *argTupleTy = inferredArgs.front().getOldType()->getAs<TupleType>(); // Let's see if inferred argument is actually a tuple inside of Paren. if (argTupleTy) { // Looks like the number of closure parameters matches number // of inferred arguments, which means we can we can emit an // error about an attempt to make use of tuple splat or tuple // destructuring and provide a proper fix-it. if (argTupleTy->getNumElements() == actualArgCount) { // In case of implicit parameters e.g. $0, $1 we // can't really provide good fix-it because // structure of parameter type itself is unclear. for (auto *param : params->getArray()) { if (param->isImplicit()) { diagnose(params->getStartLoc(), diag::closure_tuple_parameter_destructuring_implicit, argTupleTy); return true; } } auto diag = diagnose(params->getStartLoc(), diag::closure_tuple_parameter_destructuring, argTupleTy); auto *closureBody = CE->getBody(); if (!closureBody) return true; auto &sourceMgr = CS.getASTContext().SourceMgr; auto bodyStmts = closureBody->getElements(); SourceLoc bodyLoc; // If the body is empty let's put the cursor // right after "in", otherwise make it start // location of the first statement in the body. if (bodyStmts.empty()) bodyLoc = Lexer::getLocForEndOfToken(sourceMgr, CE->getInLoc()); else bodyLoc = bodyStmts.front().getStartLoc(); SmallString<64> fixIt; llvm::raw_svector_ostream OS(fixIt); // If this is multi-line closure we'd have to insert new lines // in the suggested 'let' to keep the structure of the code intact, // otherwise just use ';' to keep everything on the same line. auto inLine = sourceMgr.getLineNumber(CE->getInLoc()); auto bodyLine = sourceMgr.getLineNumber(bodyLoc); auto isMultiLineClosure = bodyLine > inLine; auto indent = bodyStmts.empty() ? "" : Lexer::getIndentationForLine( sourceMgr, bodyLoc); SmallString<16> parameter; llvm::raw_svector_ostream parameterOS(parameter); parameterOS << "("; interleave(params->getArray(), [&](const ParamDecl *param) { parameterOS << param->getNameStr(); }, [&] { parameterOS << ", "; }); parameterOS << ")"; // Check if there are any explicit types associated // with parameters, if there are, we'll have to add // type information to the replacement argument. bool explicitTypes = false; for (auto *param : params->getArray()) { if (param->getTypeLoc().getTypeRepr()) { explicitTypes = true; break; } } if (isMultiLineClosure) OS << '\n' << indent; // Let's form 'let <name> : [<type>]? = arg' expression. OS << "let " << parameterOS.str() << " = arg" << (isMultiLineClosure ? "\n" + indent : "; "); SmallString<64> argName; llvm::raw_svector_ostream nameOS(argName); if (explicitTypes) { nameOS << "(arg: " << argTupleTy->getString() << ")"; } else { nameOS << "(arg)"; } if (CE->hasSingleExpressionBody()) { // Let's see if we need to add result type to the argument/fix-it: // - if the there is a result type associated with the closure; // - and it's not a void type; // - and it hasn't been explicitly written. auto resultType = fnType->getResult(); auto hasResult = [](Type resultType) -> bool { return resultType && !resultType->isVoid(); }; auto isValidType = [](Type resultType) -> bool { return resultType && !resultType->hasUnresolvedType() && !resultType->hasTypeVariable(); }; // If there an expected result type but it hasn't been explicitly // provided, let's add it to the argument. if (hasResult(resultType) && !CE->hasExplicitResultType()) { nameOS << " -> "; if (isValidType(resultType)) nameOS << resultType->getString(); else nameOS << "<#Result#>"; } if (auto stmt = bodyStmts.front().get<Stmt *>()) { // If the body is a single expression with implicit return. if (isa<ReturnStmt>(stmt) && stmt->isImplicit()) { // And there is non-void expected result type, // because we add 'let' expression to the body // we need to make such 'return' explicit. if (hasResult(resultType)) OS << "return "; } } } diag.fixItReplace(params->getSourceRange(), nameOS.str()) .fixItInsert(bodyLoc, OS.str()); return true; } } } bool onlyAnonymousParams = std::all_of(params->begin(), params->end(), [](ParamDecl *param) { return !param->hasName(); }); // Okay, the wrong number of arguments was used, complain about that. // Before doing so, strip attributes off the function type so that they // don't confuse the issue. fnType = FunctionType::get(fnType->getParams(), fnType->getResult(), fnType->getExtInfo()); auto diag = diagnose( params->getStartLoc(), diag::closure_argument_list_tuple, fnType, inferredArgCount, actualArgCount, (actualArgCount == 1)); // If closure expects no parameters but N was given, // and all of them are anonymous let's suggest removing them. if (inferredArgCount == 0 && onlyAnonymousParams) { auto inLoc = CE->getInLoc(); auto &sourceMgr = CS.getASTContext().SourceMgr; if (inLoc.isValid()) diag.fixItRemoveChars(params->getStartLoc(), Lexer::getLocForEndOfToken(sourceMgr, inLoc)); return true; } // If the number of parameters is less than number of inferred // and all of the parameters are anonymous, let's suggest a fix-it // with the rest of the missing parameters. if (actualArgCount < inferredArgCount) { SmallString<32> fixIt; llvm::raw_svector_ostream OS(fixIt); OS << ","; auto numMissing = inferredArgCount - actualArgCount; for (unsigned i = 0; i != numMissing; ++i) { OS << ((onlyAnonymousParams) ? "_" : "<#arg#>"); OS << ((i == numMissing - 1) ? " " : ","); } diag.fixItInsertAfter(params->getEndLoc(), OS.str()); } return true; } // Coerce parameter types here only if there are no unresolved if (CS.TC.coerceParameterListToType(params, CE, fnType)) return true; expectedResultType = fnType->getResult(); } // Defend against type variables from our constraint system leaking into // recursive constraints systems formed when checking the body of the // closure. These typevars come into them when the body does name // lookups against the parameter decls. // // Handle this by rewriting the arguments to UnresolvedType(). for (auto VD : *CE->getParameters()) { if (VD->hasType() && (VD->getType()->hasTypeVariable() || VD->getType()->hasError())) { VD->setType(CS.getASTContext().TheUnresolvedType); VD->setInterfaceType(VD->getType()); } } // If this is a complex leaf closure, there is nothing more we can do. if (!CE->hasSingleExpressionBody()) return false; if (isInvalidClosureResultType(expectedResultType)) expectedResultType = Type(); // When we're type checking a single-expression closure, we need to reset the // DeclContext to this closure for the recursive type checking. Otherwise, // if there is a closure in the subexpression, we can violate invariants. { llvm::SaveAndRestore<DeclContext *> SavedDC(CS.DC, CE); // Explicitly disallow to produce solutions with unresolved type variables, // because there is no auxiliary logic which would handle that and it's // better to allow failure diagnosis to run directly on the closure body. // Note that presence of contextual type implicitly forbids such solutions, // but it's not always reset. if (expectedResultType && !CE->hasExplicitResultType()) { auto closure = CE->getSingleExpressionBody(); ConcreteDeclRef decl = nullptr; // Let's try to compute result type without mutating AST and // using expected (contextual) result type, that's going to help // diagnose situations where contextual type expected one result // type but actual closure produces a different one without explicitly // declaring it (e.g. by using anonymous parameters). auto type = CS.TC.getTypeOfExpressionWithoutApplying( closure, CS.DC, decl, FreeTypeVariableBinding::Disallow); if (type && resultTypeProcessor(type, expectedResultType)) return true; } // If the closure had an expected result type, use it. if (CE->hasExplicitResultType()) expectedResultType = CE->getExplicitResultTypeLoc().getType(); // If we couldn't diagnose anything related to the contextual result type // let's run proper type-check with expected type and try to verify it. auto CTP = expectedResultType ? CTP_ClosureResult : CTP_Unused; auto *bodyExpr = typeCheckChildIndependently(CE->getSingleExpressionBody(), expectedResultType, CTP, TCCOptions(), nullptr, false); if (!bodyExpr) return true; if (resultTypeProcessor(CS.getType(bodyExpr), expectedResultType)) return true; } // If the body of the closure looked ok, then look for a contextual type // error. This is necessary because FailureDiagnosis::diagnoseExprFailure // doesn't do this for closures. if (contextualType) { auto fnType = contextualType->getAs<AnyFunctionType>(); if (!fnType || fnType->isEqual(CS.getType(CE))) return false; auto contextualResultType = fnType->getResult(); // If the result type was unknown, it doesn't really make // sense to diagnose from expected to unknown here. if (isInvalidClosureResultType(contextualResultType)) return false; // If the closure had an explicitly written return type incompatible with // the contextual type, diagnose that. if (CE->hasExplicitResultType() && CE->getExplicitResultTypeLoc().getTypeRepr()) { auto explicitResultTy = CE->getExplicitResultTypeLoc().getType(); if (fnType && !explicitResultTy->isEqual(contextualResultType)) { auto repr = CE->getExplicitResultTypeLoc().getTypeRepr(); diagnose(repr->getStartLoc(), diag::incorrect_explicit_closure_result, explicitResultTy, fnType->getResult()) .fixItReplace(repr->getSourceRange(),fnType->getResult().getString()); return true; } } } // Otherwise, we can't produce a specific diagnostic. return false; } static bool diagnoseKeyPathUnsupportedOperations(TypeChecker &TC, KeyPathExpr *KPE) { if (KPE->isObjC()) return false; using ComponentKind = KeyPathExpr::Component::Kind; const auto components = KPE->getComponents(); if (auto *rootType = KPE->getRootType()) { if (isa<TupleTypeRepr>(rootType)) { auto first = components.front(); if (first.getKind() == ComponentKind::UnresolvedProperty) { TC.diagnose(first.getLoc(), diag::unsupported_keypath_tuple_element_reference); return true; } } } return false; } // Ported version of TypeChecker::checkObjCKeyPathExpr which works // with new Smart KeyPath feature. static bool diagnoseKeyPathComponents(ConstraintSystem &CS, KeyPathExpr *KPE, Type rootType) { auto &TC = CS.TC; // The constraint system may have been unable to resolve the actual root // type. The generic interface type of the root produces better // diagnostics in this case. if (rootType->hasUnresolvedType() && !KPE->isObjC() && KPE->getRootType()) { if (auto ident = dyn_cast<ComponentIdentTypeRepr>(KPE->getRootType())) { if (auto decl = ident->getBoundDecl()) { if (auto metaType = decl->getInterfaceType()->castTo<MetatypeType>()) { rootType = metaType->getInstanceType(); } } } } // The key path string we're forming. SmallString<32> keyPathScratch; llvm::raw_svector_ostream keyPathOS(keyPathScratch); // Captures the state of semantic resolution. enum State { Beginning, ResolvingType, ResolvingProperty, ResolvingArray, ResolvingSet, ResolvingDictionary, } state = Beginning; /// Determine whether we are currently resolving a property. auto isResolvingProperty = [&] { switch (state) { case Beginning: case ResolvingType: return false; case ResolvingProperty: case ResolvingArray: case ResolvingSet: case ResolvingDictionary: return true; } llvm_unreachable("Unhandled State in switch."); }; // The type of AnyObject, which is used whenever we don't have // sufficient type information. Type anyObjectType = TC.Context.getAnyObjectType(); // Local function to update the state after we've resolved a // component. Type currentType = rootType; auto updateState = [&](bool isProperty, Type newType) { // Strip off optionals. newType = newType->lookThroughAllOptionalTypes(); // If updating to a type, just set the new type; there's nothing // more to do. if (!isProperty) { assert(state == Beginning || state == ResolvingType); state = ResolvingType; currentType = newType; return; } // We're updating to a property. Determine whether we're looking // into a bridged Swift collection of some sort. if (auto boundGeneric = newType->getAs<BoundGenericType>()) { auto nominal = boundGeneric->getDecl(); // Array<T> if (nominal == TC.Context.getArrayDecl()) { // Further lookups into the element type. state = ResolvingArray; currentType = boundGeneric->getGenericArgs()[0]; return; } // Set<T> if (nominal == TC.Context.getSetDecl()) { // Further lookups into the element type. state = ResolvingSet; currentType = boundGeneric->getGenericArgs()[0]; return; } // Dictionary<K, V> if (nominal == TC.Context.getDictionaryDecl()) { // Key paths look into the keys of a dictionary; further // lookups into the value type. state = ResolvingDictionary; currentType = boundGeneric->getGenericArgs()[1]; return; } } // Determine whether we're looking into a Foundation collection. if (auto classDecl = newType->getClassOrBoundGenericClass()) { if (classDecl->isObjC() && classDecl->hasClangNode()) { SmallString<32> scratch; StringRef objcClassName = classDecl->getObjCRuntimeName(scratch); // NSArray if (objcClassName == "NSArray") { // The element type is unknown, so use AnyObject. state = ResolvingArray; currentType = anyObjectType; return; } // NSSet if (objcClassName == "NSSet") { // The element type is unknown, so use AnyObject. state = ResolvingSet; currentType = anyObjectType; return; } // NSDictionary if (objcClassName == "NSDictionary") { // Key paths look into the keys of a dictionary; there's no // type to help us here. state = ResolvingDictionary; currentType = anyObjectType; return; } } } // It's just a property. state = ResolvingProperty; currentType = newType; }; // Local function to perform name lookup for the current index. auto performLookup = [&](DeclBaseName componentName, SourceLoc componentNameLoc, Type &lookupType) -> LookupResult { assert(currentType && "Non-beginning state must have a type"); if (!currentType->mayHaveMembers()) return LookupResult(); // Determine the type in which the lookup should occur. If we have // a bridged value type, this will be the Objective-C class to // which it is bridged. if (auto bridgedClass = TC.Context.getBridgedToObjC(CS.DC, currentType)) lookupType = bridgedClass; else lookupType = currentType; // Look for a member with the given name within this type. return TC.lookupMember(CS.DC, lookupType, componentName); }; // Local function to print a component to the string. bool needDot = false; auto printComponent = [&](DeclBaseName component) { if (needDot) keyPathOS << "."; else needDot = true; keyPathOS << component; }; bool isInvalid = false; SmallVector<KeyPathExpr::Component, 4> resolvedComponents; for (auto &component : KPE->getComponents()) { auto componentNameLoc = component.getLoc(); DeclBaseName componentName; switch (auto kind = component.getKind()) { case KeyPathExpr::Component::Kind::UnresolvedProperty: { auto componentFullName = component.getUnresolvedDeclName(); componentName = componentFullName.getBaseIdentifier(); break; } case KeyPathExpr::Component::Kind::UnresolvedSubscript: componentName = DeclBaseName::createSubscript(); break; case KeyPathExpr::Component::Kind::Invalid: case KeyPathExpr::Component::Kind::Identity: case KeyPathExpr::Component::Kind::OptionalChain: case KeyPathExpr::Component::Kind::OptionalForce: // FIXME: Diagnose optional chaining and forcing properly. return false; case KeyPathExpr::Component::Kind::OptionalWrap: case KeyPathExpr::Component::Kind::Property: case KeyPathExpr::Component::Kind::Subscript: llvm_unreachable("already resolved!"); } // If we are resolving into a dictionary, any component is // well-formed because the keys are unknown dynamically. if (state == ResolvingDictionary) { // Just print the component unchanged; there's no checking we // can do here. printComponent(componentName); // From here, we're resolving a property. Use the current type. updateState(/*isProperty=*/true, currentType); continue; } // Look for this component. Type lookupType; LookupResult lookup = performLookup(componentName, componentNameLoc, lookupType); // If we didn't find anything, try to apply typo-correction. bool resultsAreFromTypoCorrection = false; if (!lookup) { TypoCorrectionResults corrections(TC, componentName, DeclNameLoc(componentNameLoc)); TC.performTypoCorrection(CS.DC, DeclRefKind::Ordinary, lookupType, (lookupType ? defaultMemberTypeLookupOptions : defaultUnqualifiedLookupOptions), corrections); if (currentType) TC.diagnose(componentNameLoc, diag::could_not_find_type_member, currentType, componentName); else TC.diagnose(componentNameLoc, diag::use_unresolved_identifier, componentName, false); // Note all the correction candidates. corrections.noteAllCandidates(); corrections.addAllCandidatesToLookup(lookup); isInvalid = true; if (!lookup) break; // Remember that these are from typo correction. resultsAreFromTypoCorrection = true; } // If we have more than one result, filter out unavailable or // obviously unusable candidates. if (lookup.size() > 1) { lookup.filter([&](LookupResultEntry result, bool isOuter) -> bool { // Drop unavailable candidates. if (result.getValueDecl()->getAttrs().isUnavailable(TC.Context)) return false; // Drop non-property, non-type candidates. if (!isa<VarDecl>(result.getValueDecl()) && !isa<TypeDecl>(result.getValueDecl()) && !isa<SubscriptDecl>(result.getValueDecl())) return false; return true; }); } // If all results were unavailable, fail. if (!lookup) break; // If we *still* have more than one result, fail. if (lookup.size() > 1) { // Don't diagnose ambiguities if the results are from typo correction. if (resultsAreFromTypoCorrection) break; if (lookupType) TC.diagnose(componentNameLoc, diag::ambiguous_member_overload_set, componentName); else TC.diagnose(componentNameLoc, diag::ambiguous_decl_ref, componentName); for (auto result : lookup) { TC.diagnose(result.getValueDecl(), diag::decl_declared_here, result.getValueDecl()->getFullName()); } isInvalid = true; break; } auto found = lookup.front().getValueDecl(); // Handle property references. if (auto var = dyn_cast<VarDecl>(found)) { TC.validateDecl(var); // Resolve this component to the variable we found. auto varRef = ConcreteDeclRef(var); auto resolved = KeyPathExpr::Component::forProperty(varRef, Type(), componentNameLoc); resolvedComponents.push_back(resolved); updateState(/*isProperty=*/true, var->getInterfaceType()); continue; } // Handle type references. if (auto type = dyn_cast<TypeDecl>(found)) { // We cannot refer to a type via a property. if (isResolvingProperty()) { TC.diagnose(componentNameLoc, diag::expr_keypath_type_of_property, componentName, currentType); isInvalid = true; break; } // We cannot refer to a generic type. if (type->getDeclaredInterfaceType()->hasTypeParameter()) { TC.diagnose(componentNameLoc, diag::expr_keypath_generic_type, componentName); isInvalid = true; break; } Type newType; if (lookupType && !lookupType->isAnyObject()) { newType = lookupType->getTypeOfMember(CS.DC->getParentModule(), type, type->getDeclaredInterfaceType()); } else { newType = type->getDeclaredInterfaceType(); } if (!newType) { isInvalid = true; break; } updateState(/*isProperty=*/false, newType); continue; } continue; } return isInvalid; } bool FailureDiagnosis::visitKeyPathExpr(KeyPathExpr *KPE) { if (diagnoseKeyPathUnsupportedOperations(CS.TC, KPE)) return true; auto contextualType = CS.getContextualType(); auto components = KPE->getComponents(); assert(!components.empty() && "smart key path components cannot be empty."); auto &firstComponent = components.front(); using ComponentKind = KeyPathExpr::Component::Kind; ClassDecl *klass; Type parentType, rootType, valueType; switch (firstComponent.getKind()) { case ComponentKind::UnresolvedProperty: case ComponentKind::UnresolvedSubscript: { // If there is no contextual type we can't really do anything, // as in case of unresolved member expression, which relies on // contextual information. if (!contextualType) return false; if (auto *BGT = contextualType->getAs<BoundGenericClassType>()) { auto genericArgs = BGT->getGenericArgs(); klass = BGT->getDecl(); parentType = BGT->getParent(); // Smart Key Path can either have 1 argument - root type or // two arguments - root and value type. assert(genericArgs.size() == 1 || genericArgs.size() == 2); rootType = genericArgs.front(); if (genericArgs.size() == 2) valueType = genericArgs.back(); } break; } default: return false; } // If there is no root type associated with expression we can't // really diagnose anything here, it's most likely ambiguity. if (!rootType) return false; // If we know value type, it might be contextual mismatch between // the actual type of the path vs. given by the caller. if (valueType && !valueType->hasUnresolvedType()) { struct KeyPathListener : public ExprTypeCheckListener { ClassDecl *Decl; Type ParentType; Type RootType; KeyPathListener(ClassDecl *decl, Type parent, Type root) : Decl(decl), ParentType(parent), RootType(root) {} bool builtConstraints(ConstraintSystem &cs, Expr *expr) override { auto *locator = cs.getConstraintLocator(expr); auto valueType = cs.createTypeVariable(locator); auto keyPathType = BoundGenericClassType::get(Decl, ParentType, {RootType, valueType}); cs.addConstraint(ConstraintKind::Conversion, cs.getType(expr), keyPathType, locator, /*isFavored*/ true); return false; } }; Expr *expr = KPE; KeyPathListener listener(klass, parentType, rootType); ConcreteDeclRef concreteDecl; auto derivedType = CS.TC.getTypeOfExpressionWithoutApplying( expr, CS.DC, concreteDecl, FreeTypeVariableBinding::Disallow, &listener); if (derivedType) { if (auto *BGT = derivedType->getAs<BoundGenericClassType>()) { auto derivedValueType = BGT->getGenericArgs().back(); if (!CS.TC.isConvertibleTo(valueType, derivedValueType, CS.DC)) { diagnose(KPE->getLoc(), diag::expr_smart_keypath_value_covert_to_contextual_type, derivedValueType, valueType); return true; } } } } // Looks like this is not a problem with contextual value type, let's see // if there is something wrong with the path itself, maybe one of the // components is incorrectly typed or doesn't exist... return diagnoseKeyPathComponents(CS, KPE, rootType); } // SWIFT_ENABLE_TENSORFLOW bool FailureDiagnosis:: diagnoseReverseAutoDiffExpr(ReverseAutoDiffExpr *RADE) { // TODO: Sema diagnostics for gradient expressions could be improved by // diagnosing non-differentiable arguments/non-differentiable constraints. auto gradType = CS.getType(RADE); auto gradFnType = gradType->getAs<AnyFunctionType>(); assert(gradFnType && "Gradient expression should have function type."); // If there is no contextual type, there is no way to diagnose further. auto contextualType = CS.getContextualType(); if (!contextualType) return false; // If gradient expression has a generic primal, then conversion to the // contextual type was not possible. if (gradType->hasTypeVariable()) { diagnose(RADE->getLoc(), diag::gradient_expr_incompatible_contextual_type, contextualType); return true; } return false; } bool FailureDiagnosis::visitReverseAutoDiffExpr(ReverseAutoDiffExpr *RADE) { return diagnoseReverseAutoDiffExpr(RADE); } bool FailureDiagnosis::visitPoundAssertExpr(PoundAssertExpr *PAE) { auto boolType = CS.getASTContext().getBoolDecl()->getDeclaredType(); return !typeCheckChildIndependently(PAE->getCondition(), boolType, CTP_CallArgument); } bool FailureDiagnosis::visitArrayExpr(ArrayExpr *E) { // If we had a contextual type, then it either conforms to // ExpressibleByArrayLiteral or it is an invalid contextual type. auto contextualType = CS.getContextualType(); if (!contextualType) { return false; } // If our contextual type is an optional, look through them, because we're // surely initializing whatever is inside. contextualType = contextualType->lookThroughAllOptionalTypes(); // Validate that the contextual type conforms to ExpressibleByArrayLiteral and // figure out what the contextual element type is in place. auto ALC = CS.TC.getProtocol(E->getLoc(), KnownProtocolKind::ExpressibleByArrayLiteral); if (!ALC) return visitExpr(E); // Check to see if the contextual type conforms. if (auto Conformance = CS.TC.conformsToProtocol(contextualType, ALC, CS.DC, ConformanceCheckFlags::InExpression)) { Type contextualElementType = ProtocolConformanceRef::getTypeWitnessByName( contextualType, *Conformance, CS.getASTContext().Id_ArrayLiteralElement, &CS.TC) ->getDesugaredType(); // Type check each of the subexpressions in place, passing down the contextual // type information if we have it. for (auto elt : E->getElements()) { if (typeCheckChildIndependently(elt, contextualElementType, CTP_ArrayElement) == nullptr) { return true; } } return false; } auto DLC = CS.TC.getProtocol(E->getLoc(), KnownProtocolKind::ExpressibleByDictionaryLiteral); if (!DLC) return visitExpr(E); if (CS.TC.conformsToProtocol(contextualType, DLC, CS.DC, ConformanceCheckFlags::InExpression)) { // If the contextual type conforms to ExpressibleByDictionaryLiteral and // this is an empty array, then they meant "[:]". auto numElements = E->getNumElements(); if (numElements == 0) { diagnose(E->getStartLoc(), diag::should_use_empty_dictionary_literal) .fixItInsert(E->getEndLoc(), ":"); return true; } // If the contextual type conforms to ExpressibleByDictionaryLiteral, then // they wrote "x = [1,2]" but probably meant "x = [1:2]". if ((numElements & 1) == 0 && numElements > 0) { bool isIniting = CS.getContextualTypePurpose() == CTP_Initialization; diagnose(E->getStartLoc(), diag::should_use_dictionary_literal, contextualType, isIniting); auto diag = diagnose(E->getStartLoc(), diag::meant_dictionary_lit); // Change every other comma into a colon, only if the number // of commas present matches the number of elements, because // otherwise it might a structural problem with the expression // e.g. ["a""b": 1]. const auto commaLocs = E->getCommaLocs(); if (commaLocs.size() == numElements - 1) { for (unsigned i = 0, e = numElements / 2; i != e; ++i) diag.fixItReplace(commaLocs[i*2], ":"); } return true; } return false; } // If that didn't turn up an issue, then we don't know what to do. // TODO: When a contextual type is missing, we could try to diagnose cases // where the element types mismatch... but theoretically they should type // unify to Any, so that could never happen? return false; } bool FailureDiagnosis::visitDictionaryExpr(DictionaryExpr *E) { Type contextualKeyType, contextualValueType; auto keyTypePurpose = CTP_Unused, valueTypePurpose = CTP_Unused; // If we had a contextual type, then it either conforms to // ExpressibleByDictionaryLiteral or it is an invalid contextual type. if (auto contextualType = CS.getContextualType()) { // If our contextual type is an optional, look through them, because we're // surely initializing whatever is inside. contextualType = contextualType->lookThroughAllOptionalTypes(); auto DLC = CS.TC.getProtocol( E->getLoc(), KnownProtocolKind::ExpressibleByDictionaryLiteral); if (!DLC) return visitExpr(E); // Validate the contextual type conforms to ExpressibleByDictionaryLiteral // and figure out what the contextual Key/Value types are in place. auto Conformance = CS.TC.conformsToProtocol( contextualType, DLC, CS.DC, ConformanceCheckFlags::InExpression); if (!Conformance) { diagnose(E->getStartLoc(), diag::type_is_not_dictionary, contextualType) .highlight(E->getSourceRange()); return true; } contextualKeyType = ProtocolConformanceRef::getTypeWitnessByName( contextualType, *Conformance, CS.getASTContext().Id_Key, &CS.TC) ->getDesugaredType(); contextualValueType = ProtocolConformanceRef::getTypeWitnessByName( contextualType, *Conformance, CS.getASTContext().Id_Value, &CS.TC) ->getDesugaredType(); assert(contextualKeyType && contextualValueType && "Could not find Key/Value DictionaryLiteral associated types from" " contextual type conformance"); keyTypePurpose = CTP_DictionaryKey; valueTypePurpose = CTP_DictionaryValue; } // Type check each of the subexpressions in place, passing down the contextual // type information if we have it. for (auto elt : E->getElements()) { auto TE = dyn_cast<TupleExpr>(elt); if (!TE || TE->getNumElements() != 2) continue; if (!typeCheckChildIndependently(TE->getElement(0), contextualKeyType, keyTypePurpose)) return true; if (!typeCheckChildIndependently(TE->getElement(1), contextualValueType, valueTypePurpose)) return true; } // If that didn't turn up an issue, then we don't know what to do. // TODO: When a contextual type is missing, we could try to diagnose cases // where the element types mismatch. There is no Any equivalent since they // keys need to be hashable. return false; } /// When an object literal fails to typecheck because its protocol's /// corresponding default type has not been set in the global namespace (e.g. /// _ColorLiteralType), suggest that the user import the appropriate module for /// the target. bool FailureDiagnosis::visitObjectLiteralExpr(ObjectLiteralExpr *E) { auto &TC = CS.getTypeChecker(); // SWIFT_ENABLE_TENSORFLOW // TensorFlow ops don't act like other literals. if (E->isTFOp()) return false; // Type check the argument first. auto protocol = TC.getLiteralProtocol(E); if (!protocol) return false; DeclName constrName = TC.getObjectLiteralConstructorName(E); assert(constrName); ArrayRef<ValueDecl *> constrs = protocol->lookupDirect(constrName); if (constrs.size() != 1 || !isa<ConstructorDecl>(constrs.front())) return false; auto *constr = cast<ConstructorDecl>(constrs.front()); auto paramType = TC.getObjectLiteralParameterType(E, constr); if (!typeCheckChildIndependently( E->getArg(), paramType, CTP_CallArgument)) return true; // Conditions for showing this diagnostic: // * The object literal protocol's default type is unimplemented if (TC.getDefaultType(protocol, CS.DC)) return false; // * The object literal has no contextual type if (CS.getContextualType()) return false; // Figure out what import to suggest. auto &Ctx = CS.getASTContext(); const auto &target = Ctx.LangOpts.Target; StringRef importModule; StringRef importDefaultTypeName; if (protocol == Ctx.getProtocol(KnownProtocolKind::ExpressibleByColorLiteral)) { if (target.isMacOSX()) { importModule = "AppKit"; importDefaultTypeName = "NSColor"; } else if (target.isiOS() || target.isTvOS()) { importModule = "UIKit"; importDefaultTypeName = "UIColor"; } } else if (protocol == Ctx.getProtocol( KnownProtocolKind::ExpressibleByImageLiteral)) { if (target.isMacOSX()) { importModule = "AppKit"; importDefaultTypeName = "NSImage"; } else if (target.isiOS() || target.isTvOS()) { importModule = "UIKit"; importDefaultTypeName = "UIImage"; } } else if (protocol == Ctx.getProtocol( KnownProtocolKind::ExpressibleByFileReferenceLiteral)) { importModule = "Foundation"; importDefaultTypeName = "URL"; } // Emit the diagnostic. const auto plainName = E->getLiteralKindPlainName(); TC.diagnose(E->getLoc(), diag::object_literal_default_type_missing, plainName); if (!importModule.empty()) { TC.diagnose(E->getLoc(), diag::object_literal_resolve_import, importModule, importDefaultTypeName, plainName); } return true; } bool FailureDiagnosis::visitUnresolvedMemberExpr(UnresolvedMemberExpr *E) { // If we have no contextual type, there is no way to resolve this. Just // diagnose this as an ambiguity. if (!CS.getContextualType()) return false; // OTOH, if we do have a contextual type, we can provide a more specific // error. Dig out the UnresolvedValueMember constraint for this expr node. Constraint *memberConstraint = nullptr; auto checkConstraint = [&](Constraint *C) { if (C->getKind() == ConstraintKind::UnresolvedValueMember && simplifyLocatorToAnchor(CS, C->getLocator()) == E) memberConstraint = C; }; if (CS.failedConstraint) checkConstraint(CS.failedConstraint); for (auto &C : CS.getConstraints()) { if (memberConstraint) break; checkConstraint(&C); } // If we can't find the member constraint in question, then we failed. if (!memberConstraint) return false; std::function<bool(ArrayRef<OverloadChoice>)> callback = [&]( ArrayRef<OverloadChoice> candidates) { bool hasTrailingClosure = callArgHasTrailingClosure(E->getArgument()); // Dump all of our viable candidates into a CalleeCandidateInfo & sort it // out. CalleeCandidateInfo candidateInfo(Type(), candidates, hasTrailingClosure, CS); // Filter the candidate list based on the argument we may or may not have. candidateInfo.filterContextualMemberList(E->getArgument()); // If we have multiple candidates, then we have an ambiguity. if (candidateInfo.size() != 1) { SourceRange argRange; if (auto arg = E->getArgument()) argRange = arg->getSourceRange(); diagnose(E->getNameLoc(), diag::ambiguous_member_overload_set, E->getName()) .highlight(argRange); candidateInfo.suggestPotentialOverloads(E->getNameLoc().getBaseNameLoc()); return true; } auto *argExpr = E->getArgument(); auto candidateArgTy = candidateInfo[0].getArgumentType(CS.getASTContext()); // Depending on how we matched, produce tailored diagnostics. switch (candidateInfo.closeness) { case CC_NonLValueInOut: // First argument is inout but no lvalue present. case CC_OneArgumentMismatch: // All arguments except one match. case CC_OneArgumentNearMismatch: case CC_OneGenericArgumentMismatch: case CC_OneGenericArgumentNearMismatch: case CC_GenericNonsubstitutableMismatch: case CC_SelfMismatch: // Self argument mismatches. case CC_ArgumentNearMismatch: // Argument list mismatch. case CC_ArgumentMismatch: // Argument list mismatch. llvm_unreachable("These aren't produced by filterContextualMemberList"); return false; case CC_ExactMatch: { // This is a perfect match for the arguments. // If we have an exact match, then we must have an argument list, check // it. if (candidateArgTy) { assert(argExpr && "Exact match without argument?"); if (!typeCheckArgumentChildIndependently(argExpr, candidateArgTy, candidateInfo)) return true; } // If the argument is a match, then check the result type. We might have // looked up a contextual member whose result type disagrees with the // expected result type. auto resultTy = candidateInfo[0].getResultType(); if (!resultTy) resultTy = candidateInfo[0].getUncurriedType(); if (resultTy && !CS.getContextualType()->is<UnboundGenericType>() && !CS.TC.isConvertibleTo(resultTy, CS.getContextualType(), CS.DC)) { diagnose(E->getNameLoc(), diag::expected_result_in_contextual_member, E->getName(), resultTy, CS.getContextualType()); return true; } // Otherwise, this is an exact match, return false to diagnose this as an // ambiguity. It must be some other problem, such as failing to infer a // generic argument on the enum type. return false; } case CC_Unavailable: case CC_Inaccessible: // Diagnose some simple and common errors. return candidateInfo.diagnoseSimpleErrors(E); case CC_ArgumentLabelMismatch: case CC_ArgumentCountMismatch: { // If we have no argument, the candidates must have expected one. if (!argExpr) { if (!candidateArgTy) return false; // Candidate must be incorrect for some other reason. // Pick one of the arguments that are expected as an exemplar. if (candidateArgTy->isVoid()) { // If this member is () -> T, suggest adding parentheses. diagnose(E->getNameLoc(), diag::expected_parens_in_contextual_member, E->getName()) .fixItInsertAfter(E->getEndLoc(), "()"); } else { diagnose(E->getNameLoc(), diag::expected_argument_in_contextual_member, E->getName(), candidateArgTy); } return true; } assert(argExpr && candidateArgTy && "Exact match without an argument?"); return diagnoseSingleCandidateFailures(candidateInfo, E, argExpr, E->getArgumentLabels()); } case CC_GeneralMismatch: { // Something else is wrong. // If an argument value was specified, but this member expects no // arguments, // then we fail with a nice error message. if (!candidateArgTy) { auto kind = candidateInfo[0].getDecl()->getDescriptiveKind(); bool isVoid = CS.getType(argExpr)->isVoid(); auto argumentRange = E->getArgument()->getSourceRange(); if (kind == DescriptiveDeclKind::EnumElement) { if (isVoid) { diagnose(E->getNameLoc(), diag::unexpected_arguments_in_enum_case, E->getName()) .fixItRemove(argumentRange); } else { diagnose(E->getNameLoc(), diag::unexpected_arguments_in_enum_case, E->getName()) .highlight(argumentRange); } } else { if (isVoid) { diagnose(E->getNameLoc(), diag::unexpected_arguments_in_contextual_member, kind, E->getName()) .fixItRemove(argumentRange); } else { diagnose(E->getNameLoc(), diag::unexpected_arguments_in_contextual_member, kind, E->getName()) .highlight(argumentRange); } } return true; } return false; } } llvm_unreachable("all cases should be handled"); }; return diagnoseMemberFailures(E, nullptr, memberConstraint->getKind(), memberConstraint->getMember(), memberConstraint->getFunctionRefKind(), memberConstraint->getLocator(), callback); } bool FailureDiagnosis::diagnoseMemberFailures( Expr *E, Expr *baseExpr, ConstraintKind lookupKind, DeclName memberName, FunctionRefKind funcRefKind, ConstraintLocator *locator, Optional<std::function<bool(ArrayRef<OverloadChoice>)>> callback, bool includeInaccessibleMembers) { auto isInitializer = memberName.isSimpleName(DeclBaseName::createConstructor()); // Get the referenced base expression from the failed constraint, along with // the SourceRange for the member ref. In "x.y", this returns the expr for x // and the source range for y. SourceRange memberRange; SourceLoc BaseLoc; DeclNameLoc NameLoc; Type baseTy, baseObjTy; // UnresolvedMemberExpr doesn't have "base" expression, // it's represented as ".foo", which means that we need // to get base from the context. if (auto *UME = dyn_cast<UnresolvedMemberExpr>(E)) { memberRange = E->getSourceRange(); BaseLoc = E->getLoc(); NameLoc = UME->getNameLoc(); baseTy = CS.getContextualType(); if (!baseTy) return false; // If we succeeded, get ready to do the member lookup. baseObjTy = baseTy->getRValueType(); // If the base object is already a metatype type, then something weird is // going on. For now, just generate a generic error. if (baseObjTy->is<MetatypeType>()) return false; baseTy = baseObjTy = MetatypeType::get(baseObjTy); } else { memberRange = baseExpr->getSourceRange(); if (locator) locator = simplifyLocator(CS, locator, memberRange); BaseLoc = baseExpr->getLoc(); NameLoc = DeclNameLoc(memberRange.Start); // Retypecheck the anchor type, which is the base of the member expression. baseExpr = typeCheckArbitrarySubExprIndependently(baseExpr, TCC_AllowLValue); if (!baseExpr) return true; baseTy = CS.getType(baseExpr); baseObjTy = baseTy->getWithoutSpecifierType(); } if (baseTy->is<InOutType>()) { auto diag = diagnose(baseExpr->getLoc(), diag::extraneous_address_of); if (auto *IOE = dyn_cast<InOutExpr>(baseExpr->getSemanticsProvidingExpr())) diag.fixItRemove(IOE->getStartLoc()); return true; } // If the base type is an IUO, look through it. Odds are, the code is not // trying to find a member of it. // FIXME: We need to rework this with IUOs out of the type system. // if (auto objTy = CS.lookThroughImplicitlyUnwrappedOptionalType(baseObjTy)) // baseTy = baseObjTy = objTy; // If the base of this property access is a function that takes an empty // argument list, then the most likely problem is that the user wanted to // call the function, e.g. in "a.b.c" where they had to write "a.b().c". // Produce a specific diagnostic + fixit for this situation. if (auto baseFTy = baseObjTy->getAs<AnyFunctionType>()) { if (baseExpr && baseFTy->getParams().empty()) { SourceLoc insertLoc = baseExpr->getEndLoc(); if (auto *DRE = dyn_cast<DeclRefExpr>(baseExpr)) { diagnose(baseExpr->getLoc(), diag::did_not_call_function, DRE->getDecl()->getBaseName().getIdentifier()) .fixItInsertAfter(insertLoc, "()"); return true; } if (auto *DSCE = dyn_cast<DotSyntaxCallExpr>(baseExpr)) if (auto *DRE = dyn_cast<DeclRefExpr>(DSCE->getFn())) { diagnose(baseExpr->getLoc(), diag::did_not_call_method, DRE->getDecl()->getBaseName().getIdentifier()) .fixItInsertAfter(insertLoc, "()"); return true; } diagnose(baseExpr->getLoc(), diag::did_not_call_function_value) .fixItInsertAfter(insertLoc, "()"); return true; } } // If this is a tuple, then the index needs to be valid. if (auto tuple = baseObjTy->getAs<TupleType>()) { auto baseName = memberName.getBaseName(); if (!baseName.isSpecial()) { StringRef nameStr = baseName.userFacingName(); int fieldIdx = -1; // Resolve a number reference into the tuple type. unsigned Value = 0; if (!nameStr.getAsInteger(10, Value) && Value < tuple->getNumElements()) { fieldIdx = Value; } else { fieldIdx = tuple->getNamedElementId(memberName.getBaseIdentifier()); } if (fieldIdx != -1) return false; // Lookup is valid. } diagnose(BaseLoc, diag::could_not_find_tuple_member, baseObjTy, memberName) .highlight(memberRange); return true; } // If this is initializer/constructor lookup we are dealing this. if (isInitializer) { // Let's check what is the base type we are trying to look it up on // because only MetatypeType is viable to find constructor on, as per // rules in ConstraintSystem::performMemberLookup. if (!baseTy->is<AnyMetatypeType>()) { baseTy = MetatypeType::get(baseTy, CS.getASTContext()); } } // If base type has unresolved generic parameters, such might mean // that it's initializer with erroneous argument, otherwise this would // be a simple ambiguous archetype case, neither can be diagnosed here. if (baseTy->hasTypeParameter() && baseTy->hasUnresolvedType()) return false; MemberLookupResult result = CS.performMemberLookup(lookupKind, memberName, baseTy, funcRefKind, locator, includeInaccessibleMembers); switch (result.OverallResult) { case MemberLookupResult::Unsolved: // If we couldn't resolve a specific type for the base expression, then we // cannot produce a specific diagnostic. return false; case MemberLookupResult::ErrorAlreadyDiagnosed: // If an error was already emitted, then we're done, don't emit anything // redundant. return true; case MemberLookupResult::HasResults: break; } SmallVector<OverloadChoice, 4> viableCandidatesToReport; for (auto candidate : result.ViableCandidates) if (candidate.getKind() != OverloadChoiceKind::KeyPathApplication) viableCandidatesToReport.push_back(candidate); // Since the lookup was allowing inaccessible members, let's check // if it found anything of that sort, which is easy to diagnose. bool allUnavailable = !CS.TC.getLangOpts().DisableAvailabilityChecking; bool allInaccessible = true; for (auto &member : viableCandidatesToReport) { if (!member.isDecl()) { // if there is no declaration, this choice is implicitly available. allUnavailable = false; continue; } auto decl = member.getDecl(); // Check availability of the found choice. if (!decl->getAttrs().isUnavailable(CS.getASTContext())) allUnavailable = false; if (decl->isAccessibleFrom(CS.DC)) allInaccessible = false; } // diagnoseSimpleErrors() should have diagnosed this scenario. assert(!allInaccessible || viableCandidatesToReport.empty()); if (result.UnviableCandidates.empty() && isInitializer && !baseObjTy->is<AnyMetatypeType>()) { if (auto ctorRef = dyn_cast<UnresolvedDotExpr>(E)) { // Diagnose 'super.init', which can only appear inside another // initializer, specially. if (isa<SuperRefExpr>(ctorRef->getBase())) { diagnose(BaseLoc, diag::super_initializer_not_in_initializer); return true; } // Suggest inserting a call to 'type(of:)' to construct another object // of the same dynamic type. SourceRange fixItRng = ctorRef->getNameLoc().getSourceRange(); // Surround the caller in `type(of:)`. diagnose(BaseLoc, diag::init_not_instance_member) .fixItInsert(fixItRng.Start, "type(of: ") .fixItInsertAfter(fixItRng.End, ")"); return true; } } if (viableCandidatesToReport.empty()) { // If this was an optional type let's check if the base type // has requested member, if so - generate nice error saying that // optional was not unwrapped, otherwise say that type value has // no such member. if (auto *OT = dyn_cast<OptionalType>(baseObjTy.getPointer())) { auto optionalResult = CS.performMemberLookup( lookupKind, memberName, OT->getBaseType(), funcRefKind, locator, /*includeInaccessibleMembers*/ false); switch (optionalResult.OverallResult) { case MemberLookupResult::ErrorAlreadyDiagnosed: // If an error was already emitted, then we're done, don't emit anything // redundant. return true; case MemberLookupResult::Unsolved: case MemberLookupResult::HasResults: break; } if (!optionalResult.ViableCandidates.empty()) { if (diagnoseBaseUnwrapForMemberAccess(baseExpr, baseObjTy, memberName, /* additionalOptional= */ false, memberRange)) return true; } } // FIXME: Dig out the property DeclNameLoc. diagnoseUnviableLookupResults(result, baseObjTy, baseExpr, memberName, NameLoc, BaseLoc); return true; } if (allUnavailable) { auto firstDecl = viableCandidatesToReport[0].getDecl(); // FIXME: We need the enclosing CallExpr to rewrite the argument labels. if (diagnoseExplicitUnavailability(firstDecl, BaseLoc, CS.DC, /*call*/ nullptr)) return true; } return callback.hasValue() ? (*callback)(viableCandidatesToReport) : false; } bool FailureDiagnosis::visitUnresolvedDotExpr(UnresolvedDotExpr *UDE) { auto *baseExpr = UDE->getBase(); auto *locator = CS.getConstraintLocator(UDE, ConstraintLocator::Member); if (!locator) return false; return diagnoseMemberFailures(UDE, baseExpr, ConstraintKind::ValueMember, UDE->getName(), UDE->getFunctionRefKind(), locator); } /// A TupleExpr propagate contextual type information down to its children and /// can be erroneous when there is a label mismatch etc. bool FailureDiagnosis::visitTupleExpr(TupleExpr *TE) { // If we know the requested argType to use, use computeTupleShuffle to produce // the shuffle of input arguments to destination values. It requires a // TupleType to compute the mapping from argExpr. Conveniently, it doesn't // care about the actual types though, so we can just use 'void' for them. if (!CS.getContextualType() || !CS.getContextualType()->is<TupleType>()) return visitExpr(TE); auto contextualTT = CS.getContextualType()->castTo<TupleType>(); SmallVector<TupleTypeElt, 4> ArgElts; auto voidTy = CS.getASTContext().TheEmptyTupleType; for (unsigned i = 0, e = TE->getNumElements(); i != e; ++i) ArgElts.push_back({ voidTy, TE->getElementName(i) }); auto TEType = TupleType::get(ArgElts, CS.getASTContext()); if (!TEType->is<TupleType>()) return visitExpr(TE); SmallVector<int, 4> sources; SmallVector<unsigned, 4> variadicArgs; // If the shuffle is invalid, then there is a type error. We could diagnose // it specifically here, but the general logic does a fine job so we let it // do it. if (computeTupleShuffle(TEType->castTo<TupleType>()->getElements(), contextualTT->getElements(), sources, variadicArgs)) return visitExpr(TE); // If we got a correct shuffle, we can perform the analysis of all of // the input elements, with their expected types. for (unsigned i = 0, e = sources.size(); i != e; ++i) { // If the value is taken from a default argument, ignore it. if (sources[i] == TupleShuffleExpr::DefaultInitialize || sources[i] == TupleShuffleExpr::Variadic || sources[i] == TupleShuffleExpr::CallerDefaultInitialize) continue; assert(sources[i] >= 0 && "Unknown sources index"); // Otherwise, it must match the corresponding expected argument type. unsigned inArgNo = sources[i]; TCCOptions options; if (contextualTT->getElement(i).isInOut()) options |= TCC_AllowLValue; auto actualType = contextualTT->getElementType(i); auto exprResult = typeCheckChildIndependently(TE->getElement(inArgNo), actualType, CS.getContextualTypePurpose(), options); // If there was an error type checking this argument, then we're done. if (!exprResult) return true; // If the caller expected something inout, but we didn't have // something of inout type, diagnose it. if (auto IOE = dyn_cast<InOutExpr>(exprResult->getSemanticsProvidingExpr())) { if (!contextualTT->getElement(i).isInOut()) { diagnose(exprResult->getLoc(), diag::extra_address_of, CS.getType(exprResult)->getInOutObjectType()) .highlight(exprResult->getSourceRange()) .fixItRemove(IOE->getStartLoc()); return true; } } } if (!variadicArgs.empty()) { Type varargsTy; for (auto &elt : contextualTT->getElements()) { if (elt.isVararg()) { varargsTy = elt.getVarargBaseTy(); break; } } assert(varargsTy); for (unsigned i = 0, e = variadicArgs.size(); i != e; ++i) { unsigned inArgNo = variadicArgs[i]; auto expr = typeCheckChildIndependently( TE->getElement(inArgNo), varargsTy, CS.getContextualTypePurpose()); // If there was an error type checking this argument, then we're done. if (!expr) return true; } } return false; } /// An IdentityExpr doesn't change its argument, but it *can* propagate its /// contextual type information down. bool FailureDiagnosis::visitIdentityExpr(IdentityExpr *E) { auto contextualType = CS.getContextualType(); // If we have a paren expr and our contextual type is a ParenType, remove the // paren expr sugar. if (contextualType) contextualType = contextualType->getWithoutParens(); if (!typeCheckChildIndependently(E->getSubExpr(), contextualType, CS.getContextualTypePurpose())) return true; return false; } /// A TryExpr doesn't change it's argument, nor does it change the contextual /// type. bool FailureDiagnosis::visitTryExpr(TryExpr *E) { return visit(E->getSubExpr()); } bool FailureDiagnosis::visitExpr(Expr *E) { // Check each of our immediate children to see if any of them are // independently invalid. bool errorInSubExpr = false; E->forEachImmediateChildExpr([&](Expr *Child) -> Expr* { // If we already found an error, stop checking. if (errorInSubExpr) return Child; // Otherwise just type check the subexpression independently. If that // succeeds, then we stitch the result back into our expression. if (typeCheckChildIndependently(Child, TCC_AllowLValue)) return Child; // Otherwise, it failed, which emitted a diagnostic. Keep track of this // so that we don't emit multiple diagnostics. errorInSubExpr = true; return Child; }); // If any of the children were errors, we're done. if (errorInSubExpr) return true; // Otherwise, produce a more generic error. return false; } bool FailureDiagnosis::diagnoseExprFailure() { assert(expr); // Our general approach is to do a depth first traversal of the broken // expression tree, type checking as we go. If we find a subtree that cannot // be type checked on its own (even to an incomplete type) then that is where // we focus our attention. If we do find a type, we use it to check for // contextual type mismatches. return visit(expr); } /// Given a specific expression and the remnants of the failed constraint /// system, produce a specific diagnostic. /// /// This is guaranteed to always emit an error message. /// void ConstraintSystem::diagnoseFailureForExpr(Expr *expr) { // Continue simplifying any active constraints left in the system. We can end // up with them because the solver bails out as soon as it sees a Failure. We // don't want to leave them around in the system because later diagnostics // will assume they are unsolvable and may otherwise leave the system in an // inconsistent state. simplify(/*ContinueAfterFailures*/true); // Look through RebindSelfInConstructorExpr to avoid weird Sema issues. if (auto *RB = dyn_cast<RebindSelfInConstructorExpr>(expr)) expr = RB->getSubExpr(); FailureDiagnosis diagnosis(expr, *this); // Now, attempt to diagnose the failure from the info we've collected. if (diagnosis.diagnoseExprFailure()) return; // If this is a contextual conversion problem, dig out some information. if (diagnosis.diagnoseContextualConversionError(expr, getContextualType(), getContextualTypePurpose())) return; // If we can diagnose a problem based on the constraints left laying around in // the system, do so now. if (diagnosis.diagnoseConstraintFailure()) return; // If no one could find a problem with this expression or constraint system, // then it must be well-formed... but is ambiguous. Handle this by diagnostic // various cases that come up. diagnosis.diagnoseAmbiguity(expr); } static bool hasGenericParameter(const GenericTypeDecl *generic, GenericTypeParamType *paramTy) { auto *decl = paramTy->getDecl(); if (!decl) return false; return decl->getDeclContext() == generic; } static void noteGenericParameterSource(const TypeLoc &loc, GenericTypeParamType *paramTy, ConstraintSystem &cs) { const GenericTypeDecl *FoundDecl = nullptr; const ComponentIdentTypeRepr *FoundGenericTypeBase = nullptr; // Walk the TypeRepr to find the type in question. if (auto typerepr = loc.getTypeRepr()) { struct FindGenericTypeDecl : public ASTWalker { const GenericTypeDecl *FoundDecl = nullptr; const ComponentIdentTypeRepr *FoundGenericTypeBase = nullptr; GenericTypeParamType *ParamTy; FindGenericTypeDecl(GenericTypeParamType *ParamTy) : ParamTy(ParamTy) {} bool walkToTypeReprPre(TypeRepr *T) override { // If we already emitted the note, we're done. if (FoundDecl) return false; if (auto ident = dyn_cast<ComponentIdentTypeRepr>(T)) { auto *generic = dyn_cast_or_null<GenericTypeDecl>(ident->getBoundDecl()); if (generic && hasGenericParameter(generic, ParamTy)) { FoundDecl = generic; FoundGenericTypeBase = ident; return false; } } // Keep walking. return true; } } findGenericTypeDecl(paramTy); typerepr->walk(findGenericTypeDecl); FoundDecl = findGenericTypeDecl.FoundDecl; FoundGenericTypeBase = findGenericTypeDecl.FoundGenericTypeBase; } // If we didn't find the type in the TypeRepr, fall back to the type in the // type checked expression. if (!FoundDecl) { if (const GenericTypeDecl *generic = loc.getType()->getAnyGeneric()) if (hasGenericParameter(generic, paramTy)) FoundDecl = generic; } auto &tc = cs.getTypeChecker(); if (FoundDecl) { Type type; if (auto *nominal = dyn_cast<NominalTypeDecl>(FoundDecl)) type = nominal->getDeclaredType(); else if (auto *typeAlias = dyn_cast<TypeAliasDecl>(FoundDecl)) type = typeAlias->getUnboundGenericType(); else type = FoundDecl->getDeclaredInterfaceType(); tc.diagnose(FoundDecl, diag::archetype_declared_in_type, paramTy, type); } if (FoundGenericTypeBase && !isa<GenericIdentTypeRepr>(FoundGenericTypeBase)){ assert(FoundDecl); // If we can, prefer using any types already fixed by the constraint system. // This lets us produce fixes like `Pair<Int, Any>` instead of defaulting to // `Pair<Any, Any>`. // Right now we only handle this when the type that's at fault is the // top-level type passed to this function. auto type = loc.getType(); if (!type) type = cs.getType(loc); ArrayRef<Type> genericArgs; if (auto *boundGenericTy = type->getAs<BoundGenericType>()) { if (boundGenericTy->getDecl() == FoundDecl) genericArgs = boundGenericTy->getGenericArgs(); } auto getPreferredType = [&](const GenericTypeParamDecl *genericParam) -> Type { // If we were able to get the generic arguments (i.e. the types used at // FoundDecl's use site), we can prefer those... if (genericArgs.empty()) return Type(); Type preferred = genericArgs[genericParam->getIndex()]; if (!preferred || preferred->hasError()) return Type(); // ...but only if they were actually resolved by the constraint system // despite the failure. Type maybeFixedType = cs.getFixedTypeRecursive(preferred, /*wantRValue*/true); if (maybeFixedType->hasTypeVariable() || maybeFixedType->hasUnresolvedType()) { return Type(); } return maybeFixedType; }; SmallString<64> genericParamBuf; if (tc.getDefaultGenericArgumentsString(genericParamBuf, FoundDecl, getPreferredType)) { tc.diagnose(FoundGenericTypeBase->getLoc(), diag::unbound_generic_parameter_explicit_fix) .fixItInsertAfter(FoundGenericTypeBase->getEndLoc(), genericParamBuf); } } } std::pair<Type, ContextualTypePurpose> FailureDiagnosis::validateContextualType(Type contextualType, ContextualTypePurpose CTP) { if (!contextualType) return {contextualType, CTP}; // If we're asked to convert to an autoclosure, then we really want to // convert to the result of it. if (auto *FT = contextualType->getAs<AnyFunctionType>()) if (FT->isAutoClosure()) contextualType = FT->getResult(); // Since some of the contextual types might be tuples e.g. subscript argument // is a tuple or paren wrapping a tuple, it's required to recursively check // its elements to determine nullability of the contextual type, because it // might contain archetypes. std::function<bool(Type)> shouldNullifyType = [&](Type type) -> bool { switch (type->getDesugaredType()->getKind()) { case TypeKind::Archetype: case TypeKind::Unresolved: return true; case TypeKind::BoundGenericEnum: case TypeKind::BoundGenericClass: case TypeKind::BoundGenericStruct: case TypeKind::UnboundGeneric: case TypeKind::GenericFunction: case TypeKind::Metatype: return type->hasUnresolvedType(); case TypeKind::Tuple: { auto tupleType = type->getAs<TupleType>(); for (auto &element : tupleType->getElements()) { if (shouldNullifyType(element.getType())) return true; } break; } default: return false; } return false; }; bool shouldNullify = false; if (auto objectType = contextualType->getWithoutSpecifierType()) { // Note that simply checking for `objectType->hasUnresolvedType()` is not // appropriate in this case standalone, because if it's in a function, // for example, or inout type, we still want to preserve it's skeleton /// because that helps to diagnose inout argument issues. Complete // nullification is only appropriate for generic types with unresolved // types or standalone archetypes because that's going to give // sub-expression solver a chance to try and compute type as it sees fit // and higher level code would have a chance to check it, which avoids // diagnostic messages like `cannot convert (_) -> _ to (Int) -> Void`. shouldNullify = shouldNullifyType(objectType); } // If the conversion type contains no info, drop it. if (shouldNullify) return {Type(), CTP_Unused}; // Remove all of the potentially leftover type variables or type parameters // from the contextual type to be used by new solver. contextualType = replaceTypeParametersWithUnresolved(contextualType); contextualType = replaceTypeVariablesWithUnresolved(contextualType); return {contextualType, CTP}; } /// Check the specified closure to see if it is a multi-statement closure with /// an uninferred type. If so, diagnose the problem with an error and return /// true. bool FailureDiagnosis:: diagnoseAmbiguousMultiStatementClosure(ClosureExpr *closure) { if (closure->hasSingleExpressionBody() || closure->hasExplicitResultType()) return false; auto closureType = CS.getType(closure)->getAs<AnyFunctionType>(); if (!closureType || !(closureType->getResult()->hasUnresolvedType() || closureType->getResult()->hasTypeVariable())) return false; // Okay, we have a multi-statement closure expr that has no inferred result, // type, in the context of a larger expression. The user probably expected // the compiler to infer the result type of the closure from the body of the // closure, which Swift doesn't do for multi-statement closures. Try to be // helpful by digging into the body of the closure, looking for a return // statement, and inferring the result type from it. If we can figure that // out, we can produce a fixit hint. class ReturnStmtFinder : public ASTWalker { SmallVectorImpl<ReturnStmt*> &returnStmts; public: ReturnStmtFinder(SmallVectorImpl<ReturnStmt*> &returnStmts) : returnStmts(returnStmts) {} // Walk through statements, so we find returns hiding in if/else blocks etc. std::pair<bool, Stmt *> walkToStmtPre(Stmt *S) override { // Keep track of any return statements we find. if (auto RS = dyn_cast<ReturnStmt>(S)) returnStmts.push_back(RS); return { true, S }; } // Don't walk into anything else, since they cannot contain statements // that can return from the current closure. std::pair<bool, Expr *> walkToExprPre(Expr *E) override { return { false, E }; } std::pair<bool, Pattern*> walkToPatternPre(Pattern *P) override { return { false, P }; } bool walkToDeclPre(Decl *D) override { return false; } bool walkToTypeLocPre(TypeLoc &TL) override { return false; } bool walkToTypeReprPre(TypeRepr *T) override { return false; } bool walkToParameterListPre(ParameterList *PL) override { return false; } }; SmallVector<ReturnStmt*, 4> Returns; closure->getBody()->walk(ReturnStmtFinder(Returns)); // If we found a return statement inside of the closure expression, then go // ahead and type check the body to see if we can determine a type. for (auto RS : Returns) { llvm::SaveAndRestore<DeclContext *> SavedDC(CS.DC, closure); // Otherwise, we're ok to type check the subexpr. Type resultType; if (RS->hasResult()) { auto resultExpr = RS->getResult(); ConcreteDeclRef decl = nullptr; // If return expression uses closure parameters, which have/are // type variables, such means that we won't be able to // type-check result correctly and, unfortunately, // we are going to leak type variables from the parent // constraint system through declaration types. bool hasUnresolvedParams = false; resultExpr->forEachChildExpr([&](Expr *childExpr) -> Expr *{ if (auto DRE = dyn_cast<DeclRefExpr>(childExpr)) { if (auto param = dyn_cast<ParamDecl>(DRE->getDecl())) { auto paramType = param->hasValidSignature() ? param->getType() : Type(); if (!paramType || paramType->hasTypeVariable()) { hasUnresolvedParams = true; return nullptr; } } } return childExpr; }); if (hasUnresolvedParams) continue; CS.TC.preCheckExpression(resultExpr, CS.DC); // Obtain type of the result expression without applying solutions, // because otherwise this might result in leaking of type variables, // since we are not resetting result statement and if expression is // successfully type-checked its type cleanup is going to be disabled // (we are allowing unresolved types), and as a side-effect it might // also be transformed e.g. OverloadedDeclRefExpr -> DeclRefExpr. auto type = CS.TC.getTypeOfExpressionWithoutApplying( resultExpr, CS.DC, decl, FreeTypeVariableBinding::UnresolvedType); if (type) resultType = type; } // If we found a type, presuppose it was the intended result and insert a // fixit hint. if (resultType && !isUnresolvedOrTypeVarType(resultType)) { std::string resultTypeStr = resultType->getString(); // If there is a location for an 'in' token, then the argument list was // specified somehow but no return type was. Insert a "-> ReturnType " // before the in token. if (closure->getInLoc().isValid()) { diagnose(closure->getLoc(), diag::cannot_infer_closure_result_type) .fixItInsert(closure->getInLoc(), "-> " + resultTypeStr + " "); return true; } // Otherwise, the closure must take zero arguments. We know this // because the if one or more argument is specified, a multi-statement // closure *must* name them, or explicitly ignore them with "_ in". // // As such, we insert " () -> ReturnType in " right after the '{' that // starts the closure body. auto insertString = " () -> " + resultTypeStr + " " + "in "; diagnose(closure->getLoc(), diag::cannot_infer_closure_result_type) .fixItInsertAfter(closure->getBody()->getLBraceLoc(), insertString); return true; } } diagnose(closure->getLoc(), diag::cannot_infer_closure_result_type); return true; } /// Check the associated constraint system to see if it has any archetypes /// not properly resolved or missing. If so, diagnose the problem with /// an error and return true. bool FailureDiagnosis::diagnoseAmbiguousGenericParameters() { using GenericParameter = std::tuple<GenericTypeParamType *, ConstraintLocator *, unsigned>; llvm::SmallVector<GenericParameter, 2> unboundParams; // Check out all of the type variables lurking in the system. If any free // type variables were created when opening generic parameters, diagnose // that the generic parameter could not be inferred. for (auto tv : CS.getTypeVariables()) { auto &impl = tv->getImpl(); if (impl.hasRepresentativeOrFixed()) continue; auto *paramTy = impl.getGenericParameter(); if (!paramTy) continue; // Number of constraints related to particular unbound parameter // is significant indicator of the problem, because if there are // no constraints associated with it, that means it can't ever be resolved, // such helps to diagnose situations like: struct S<A, B> { init(_ a: A) {}} // because type B would have no constraints associated with it. unsigned numConstraints = 0; { llvm::SetVector<Constraint *> constraints; CS.getConstraintGraph().gatherConstraints( tv, constraints, ConstraintGraph::GatheringKind::EquivalenceClass, [&](Constraint *constraint) -> bool { // We are not interested in ConformsTo constraints because // we can't derive any concrete type information from them. if (constraint->getKind() == ConstraintKind::ConformsTo) return false; if (constraint->getKind() == ConstraintKind::Bind) { if (auto locator = constraint->getLocator()) { auto anchor = locator->getAnchor(); if (anchor && isa<UnresolvedDotExpr>(anchor)) return false; } } return true; }); numConstraints = constraints.size(); } auto locator = impl.getLocator(); unboundParams.emplace_back(paramTy, locator, numConstraints); } // We've found unbound generic parameters, let's diagnose // based on the number of constraints each one is related to. if (!unboundParams.empty()) { // Let's prioritize generic parameters that don't have any constraints // associated. std::stable_sort(unboundParams.begin(), unboundParams.end(), [](GenericParameter a, GenericParameter b) { return std::get<2>(a) < std::get<2>(b); }); auto param = unboundParams.front(); diagnoseAmbiguousGenericParameter(std::get<0>(param), std::get<1>(param)->getAnchor()); return true; } return false; } /// Emit an error message about an unbound generic parameter existing, and /// emit notes referring to the target of a diagnostic, e.g., the function /// or parameter being used. void FailureDiagnosis:: diagnoseAmbiguousGenericParameter(GenericTypeParamType *paramTy, Expr *anchor) { auto &tc = CS.getTypeChecker(); // The generic parameter may come from the explicit type in a cast expression. if (auto *ECE = dyn_cast_or_null<ExplicitCastExpr>(anchor)) { tc.diagnose(ECE->getLoc(), diag::unbound_generic_parameter_cast, paramTy, ECE->getCastTypeLoc().getType()) .highlight(ECE->getCastTypeLoc().getSourceRange()); // Emit a note specifying where this came from, if we can find it. noteGenericParameterSource(ECE->getCastTypeLoc(), paramTy, CS); return; } // A very common cause of this diagnostic is a situation where a closure expr // has no inferred type, due to being a multiline closure. Check to see if // this is the case and (if so), speculatively diagnose that as the problem. bool didDiagnose = false; expr->forEachChildExpr([&](Expr *subExpr) -> Expr*{ auto closure = dyn_cast<ClosureExpr>(subExpr); if (!didDiagnose && closure) didDiagnose = diagnoseAmbiguousMultiStatementClosure(closure); return subExpr; }); if (didDiagnose) return; // Otherwise, emit an error message on the expr we have, and emit a note // about where the generic parameter came from. tc.diagnose(expr->getLoc(), diag::unbound_generic_parameter, paramTy); // If we have an anchor, drill into it to emit a // "note: generic parameter declared here". if (!anchor) return; if (auto TE = dyn_cast<TypeExpr>(anchor)) { // Emit a note specifying where this came from, if we can find it. noteGenericParameterSource(TE->getTypeLoc(), paramTy, CS); return; } ConcreteDeclRef resolved; // Simple case: direct reference to a declaration. if (auto dre = dyn_cast<DeclRefExpr>(anchor)) resolved = dre->getDeclRef(); // Simple case: direct reference to a declaration. if (auto MRE = dyn_cast<MemberRefExpr>(anchor)) resolved = MRE->getMember(); if (auto OCDRE = dyn_cast<OtherConstructorDeclRefExpr>(anchor)) resolved = OCDRE->getDeclRef(); // We couldn't resolve the locator to a declaration, so we're done. if (!resolved) return; auto decl = resolved.getDecl(); if (auto FD = dyn_cast<FuncDecl>(decl)) { auto name = FD->getFullName(); auto diagID = name.isOperator() ? diag::note_call_to_operator : diag::note_call_to_func; tc.diagnose(decl, diagID, name); return; } // FIXME: Specialize for implicitly-generated constructors. if (isa<ConstructorDecl>(decl)) { tc.diagnose(decl, diag::note_call_to_initializer); return; } if (auto PD = dyn_cast<ParamDecl>(decl)) { tc.diagnose(decl, diag::note_init_parameter, PD->getName()); return; } // FIXME: Other decl types too. } /// Emit an ambiguity diagnostic about the specified expression. void FailureDiagnosis::diagnoseAmbiguity(Expr *E) { // First, let's try to diagnose any problems related to ambiguous // generic parameters present in the constraint system. if (diagnoseAmbiguousGenericParameters()) return; // Unresolved/Anonymous ClosureExprs are common enough that we should give // them tailored diagnostics. if (auto CE = dyn_cast<ClosureExpr>(E->getValueProvidingExpr())) { // If this is a multi-statement closure with no explicit result type, emit // a note to clue the developer in. if (diagnoseAmbiguousMultiStatementClosure(CE)) return; diagnose(E->getLoc(), diag::cannot_infer_closure_type) .highlight(E->getSourceRange()); return; } // A DiscardAssignmentExpr (spelled "_") needs contextual type information to // infer its type. If we see one at top level, diagnose that it must be part // of an assignment so we don't get a generic "expression is ambiguous" error. if (isa<DiscardAssignmentExpr>(E)) { diagnose(E->getLoc(), diag::discard_expr_outside_of_assignment) .highlight(E->getSourceRange()); return; } // Diagnose ".foo" expressions that lack context specifically. if (auto UME = dyn_cast<UnresolvedMemberExpr>(E->getSemanticsProvidingExpr())) { if (!CS.getContextualType()) { diagnose(E->getLoc(), diag::unresolved_member_no_inference,UME->getName()) .highlight(SourceRange(UME->getDotLoc(), UME->getNameLoc().getSourceRange().End)); return; } } // Diagnose empty collection literals that lack context specifically. if (auto CE = dyn_cast<CollectionExpr>(E->getSemanticsProvidingExpr())) { if (CE->getNumElements() == 0) { diagnose(E->getLoc(), diag::unresolved_collection_literal) .highlight(E->getSourceRange()); return; } } // Diagnose 'nil' without a contextual type. if (isa<NilLiteralExpr>(E->getSemanticsProvidingExpr())) { diagnose(E->getLoc(), diag::unresolved_nil_literal) .highlight(E->getSourceRange()); return; } // A very common cause of this diagnostic is a situation where a closure expr // has no inferred type, due to being a multiline closure. Check to see if // this is the case and (if so), speculatively diagnose that as the problem. bool didDiagnose = false; E->forEachChildExpr([&](Expr *subExpr) -> Expr*{ auto closure = dyn_cast<ClosureExpr>(subExpr); if (!didDiagnose && closure) didDiagnose = diagnoseAmbiguousMultiStatementClosure(closure); return subExpr; }); if (didDiagnose) return; // Attempt to re-type-check the entire expression, allowing ambiguity, but // ignoring a contextual type. if (expr == E) { auto exprType = getTypeOfTypeCheckedChildIndependently(expr); // If it failed and diagnosed something, then we're done. if (!exprType) return; // If we were able to find something more specific than "unknown" (perhaps // something like "[_:_]" for a dictionary literal), include it in the // diagnostic. if (!isUnresolvedOrTypeVarType(exprType)) { diagnose(E->getLoc(), diag::specific_type_of_expression_is_ambiguous, exprType) .highlight(E->getSourceRange()); return; } } // If there are no posted constraints or failures, then there was // not enough contextual information available to infer a type for the // expression. diagnose(E->getLoc(), diag::type_of_expression_is_ambiguous) .highlight(E->getSourceRange()); } /// If an UnresolvedDotExpr, SubscriptMember, etc has been resolved by the /// constraint system, return the decl that it references. ValueDecl *ConstraintSystem::findResolvedMemberRef(ConstraintLocator *locator) { auto *resolvedOverloadSets = this->getResolvedOverloadSets(); if (!resolvedOverloadSets) return nullptr; // Search through the resolvedOverloadSets to see if we have a resolution for // this member. This is an O(n) search, but only happens when producing an // error diagnostic. for (auto resolved = resolvedOverloadSets; resolved; resolved = resolved->Previous) { if (resolved->Locator != locator) continue; // We only handle the simplest decl binding. if (resolved->Choice.getKind() != OverloadChoiceKind::Decl) return nullptr; return resolved->Choice.getDecl(); } return nullptr; } bool swift::diagnoseBaseUnwrapForMemberAccess(Expr *baseExpr, Type baseType, DeclName memberName, bool resultOptional, SourceRange memberRange) { auto unwrappedBaseType = baseType->getOptionalObjectType(); if (!unwrappedBaseType) return false; ASTContext &ctx = baseType->getASTContext(); DiagnosticEngine &diags = ctx.Diags; diags.diagnose(baseExpr->getLoc(), diag::optional_base_not_unwrapped, baseType, memberName, unwrappedBaseType); // FIXME: It would be nice to immediately offer "base?.member ?? defaultValue" // for non-optional results where that would be appropriate. For the moment // always offering "?" means that if the user chooses chaining, we'll end up // in MissingOptionalUnwrapFailure:diagnose() to offer a default value during // the next compile. diags.diagnose(baseExpr->getLoc(), diag::optional_base_chain, memberName) .fixItInsertAfter(baseExpr->getEndLoc(), "?"); if (!resultOptional) { diags.diagnose(baseExpr->getLoc(), diag::unwrap_with_force_value) .fixItInsertAfter(baseExpr->getEndLoc(), "!"); } return true; }
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r8 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0xb25f, %rsi clflush (%rsi) nop nop sub %rax, %rax movb (%rsi), %r11b nop nop nop nop dec %r8 lea addresses_A_ht+0x1b26f, %rsi lea addresses_normal_ht+0x1a65f, %rdi nop nop nop nop add $38181, %rax mov $26, %rcx rep movsq nop nop cmp %rdi, %rdi lea addresses_normal_ht+0xfe5f, %rsi lea addresses_WT_ht+0x16a87, %rdi clflush (%rdi) nop add $61217, %rdx mov $122, %rcx rep movsw nop nop nop nop nop xor %rsi, %rsi lea addresses_A_ht+0x1a5f, %rsi lea addresses_D_ht+0xd79f, %rdi nop nop nop nop nop xor $9962, %r8 mov $4, %rcx rep movsl nop nop nop cmp %rdi, %rdi lea addresses_A_ht+0x775f, %rsi lea addresses_D_ht+0x35df, %rdi nop nop nop nop nop dec %r8 mov $119, %rcx rep movsw sub $5965, %rdi lea addresses_normal_ht+0x4b9f, %rsi lea addresses_normal_ht+0x505f, %rdi nop nop nop nop dec %r10 mov $118, %rcx rep movsb xor %rcx, %rcx lea addresses_WT_ht+0xb0e7, %rsi lea addresses_A_ht+0x17735, %rdi clflush (%rsi) nop and $19561, %rax mov $18, %rcx rep movsl nop and $3393, %r8 lea addresses_WT_ht+0x13c11, %rsi lea addresses_WC_ht+0x5f, %rdi nop nop cmp %r11, %r11 mov $113, %rcx rep movsw nop nop nop nop nop add %rcx, %rcx lea addresses_WT_ht+0x17d1f, %rsi lea addresses_UC_ht+0x86e9, %rdi nop cmp %r8, %r8 mov $97, %rcx rep movsl nop nop add %rsi, %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r8 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r13 push %r14 push %r15 push %r8 push %rsi // Store lea addresses_PSE+0x72df, %r10 nop nop nop sub $23530, %r13 mov $0x5152535455565758, %r15 movq %r15, (%r10) nop nop nop and $43069, %r13 // Store mov $0x7ede380000000414, %r8 nop nop and $56848, %rsi mov $0x5152535455565758, %r13 movq %r13, %xmm4 vmovups %ymm4, (%r8) nop nop sub $17303, %rsi // Store lea addresses_PSE+0x3a5f, %r12 nop add $48077, %r14 mov $0x5152535455565758, %rsi movq %rsi, (%r12) nop nop nop nop nop add $39083, %r8 // Store lea addresses_D+0x80ff, %r15 nop nop nop nop inc %r8 mov $0x5152535455565758, %r14 movq %r14, (%r15) nop nop nop inc %r14 // Faulty Load lea addresses_PSE+0x1425f, %r12 nop nop nop nop nop and $3821, %r13 mov (%r12), %si lea oracles, %r15 and $0xff, %rsi shlq $12, %rsi mov (%r15,%rsi,1), %rsi pop %rsi pop %r8 pop %r15 pop %r14 pop %r13 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 6}} {'OP': 'STOR', 'dst': {'type': 'addresses_NC', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 10}} {'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 5}} [Faulty Load] {'src': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 2, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 11}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}} {'src': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}} {'src': {'type': 'addresses_A_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}} {'src': {'type': 'addresses_A_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 7, 'same': False}} {'src': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}} {'src': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}} {'src': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}} {'src': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}} {'33': 4409} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
# prototype-0--0 ldsi s0, 10 # 0 ldsi s1, 11 # 1 startopen 1, s0 # 2 stopopen 1, c0 # 3 print_char 32 # 4 print_char 97 # 5 print_char 61 # 6 print_reg c0 # 7 print_char 10 # 8 private_output s1, 0, 0 # 9 restart # 10
/** * Copyright (c) 2020 Horizon Robotics. All rights reserved. * @File: ClassifyPredictor.cc * @Brief: definition of the ClassifyPredictor * @Author: zhe.sun * @Email: zhe.sun@horizon.ai * @Date: 2020-08-30 14:28:17 * @Last Modified by: zhe.sun * @Last Modified time: 2020-08-30 16:19:08 */ #include "PredictMethod/Predictors/ClassifyPredictor.h" #include <vector> #include <memory> #include "hobotxstream/profiler.h" #include "hobotxsdk/xstream_data.h" #include "hobotlog/hobotlog.hpp" #include "horizon/vision_type/vision_type.hpp" #ifdef X3 #include "./bpu_predict_x3.h" #endif using hobot::vision::BBox; namespace xstream { std::vector<BaseDataPtr> ClassifyPredictor::Do( const std::vector<BaseDataPtr> &input, const xstream::InputParamPtr &param) { std::vector<BaseDataPtr> output; output = RunSingleFrame(input); return output; } std::vector<BaseDataPtr> ClassifyPredictor::RunSingleFrame( const std::vector<BaseDataPtr> &frame_input) { LOGD << "ClassifyPredictor RunSingleFrame"; HOBOT_CHECK(frame_input.size() == 2); auto rois = std::static_pointer_cast<BaseDataVector>(frame_input[0]); auto xstream_img = std::static_pointer_cast<XStreamData< std::shared_ptr<hobot::vision::ImageFrame>>>(frame_input[1]); auto pyramid = std::static_pointer_cast< hobot::vision::PymImageFrame>(xstream_img->value); std::vector<BaseDataPtr> frame_output(1); auto async_data = std::make_shared<XStreamData<std::shared_ptr< hobot::vision::AsyncData>>>(); frame_output[0] = async_data; async_data->value.reset(new hobot::vision::AsyncData()); async_data->value->model_input_height = model_input_height_; async_data->value->model_input_width = model_input_width_; int box_num = rois->datas_.size(); std::vector<int> valid_box(box_num, 1); std::vector<BPU_BBOX> boxes; for (int roi_idx = 0; roi_idx < box_num; roi_idx++) { auto &roi = rois->datas_[roi_idx]; auto p_roi = std::static_pointer_cast<XStreamData<BBox>>(roi); if (p_roi->state_ != xstream::DataState::VALID) { valid_box[roi_idx] = 0; } else { boxes.push_back(BPU_BBOX{p_roi->value.x1, p_roi->value.y1, p_roi->value.x2, p_roi->value.y2, p_roi->value.score, 0, true}); LOGD << "box: " << p_roi->value; } } { RUN_PROCESS_TIME_PROFILER("Run Classify Model"); RUN_FPS_PROFILER("Run Classify Model"); int resizable_cnt = 0; if (boxes.size() <= 0) { LOGD << "no box to cnn"; return frame_output; } // output_tensors std::shared_ptr<std::vector<BPU_TENSOR_S>> output_tensors = std::make_shared<std::vector<BPU_TENSOR_S>>(); PrepareOutputTensor(output_tensors, boxes.size()); std::shared_ptr<BPU_TASK_HANDLE> task_handle = std::make_shared<BPU_TASK_HANDLE>(); BPU_RUN_CTRL_S run_ctrl{2, 1}; #ifdef X2 int ret = HB_BPU_runModelWithBbox( bpu_model_.get(), reinterpret_cast<BPU_ADDR_INFO_S*>(&pyramid->img.down_scale[0]), pyramid->img.ds_pym_layer, boxes.data(), boxes.size(), output_tensors->data(), bpu_model_->output_num, &run_ctrl, false, &resizable_cnt, task_handle.get()); #endif #ifdef X3 bpu_predict_x3::PyramidResult bpu_predict_pyramid; Convert(*pyramid, bpu_predict_pyramid); int ret = HB_BPU_runModelWithBbox( bpu_model_.get(), reinterpret_cast<BPU_ADDR_INFO_S*>( &bpu_predict_pyramid.result_info.down_scale[0]), bpu_predict_pyramid.result_info.ds_pym_layer, boxes.data(), boxes.size(), output_tensors->data(), bpu_model_->output_num, &run_ctrl, true, &resizable_cnt, task_handle.get()); #endif if (ret != 0) { LOGE << "RunModelWithBBox failed, " << HB_BPU_getErrorName(ret); ReleaseTensor(output_tensors); // release BPU_TASK_HANDLE HB_BPU_releaseTask(task_handle.get()); if (resizable_cnt == 0) { LOGI << "no box pass resizer"; } return frame_output; } LOGD << "resizeable box:" << resizable_cnt; for (int i = 0, bpu_box_idx = 0; i < box_num; i++) { if (valid_box[i]) { valid_box[i] = boxes[bpu_box_idx].resizable; bpu_box_idx++; } } #if 0 { // test post-process int layer_size = 1; for (int32_t i = 0, mxnet_rlt_idx = 0; i < box_num; i++) { if (valid_box[i]) { std::vector<std::vector<int8_t>> mxnet_rlt(1); // object i: layer for (int j = 0; j < layer_size; j++) { mxnet_rlt[j].resize(2); // real_nhwc HB_SYS_flushMemCache(&(*output_tensors)[j].data, HB_SYS_MEM_CACHE_INVALIDATE); int output_size = 1; for (int dim = 0; dim < bpu_model_->outputs[j].aligned_shape.ndim; dim++) { output_size *= bpu_model_->outputs[j].aligned_shape.d[dim]; } if (bpu_model_->outputs[j].data_type == BPU_TYPE_TENSOR_F32 || bpu_model_->outputs[j].data_type == BPU_TYPE_TENSOR_S32 || bpu_model_->outputs[j].data_type == BPU_TYPE_TENSOR_U32) { output_size *= 4; } int raw_idx = mxnet_rlt_idx * output_size; ConvertOutputToMXNet(reinterpret_cast<int8_t *>( (*output_tensors)[j].data.virAddr)+raw_idx, mxnet_rlt[j].data(), j); // test auto mxnet_out = reinterpret_cast<const float *>(mxnet_rlt[0].data()); std::cout << mxnet_out[0] << std::endl; } mxnet_rlt_idx++; } } ReleaseTensor(output_tensors); } #endif // output_tensors传递给async_data async_data->value->input_tensors = nullptr; // resizer model无input_tensor async_data->value->output_tensors = output_tensors; async_data->value->task_handle = task_handle; async_data->value->bpu_model = bpu_model_; async_data->value->valid_box = valid_box; return frame_output; } } #if 0 void ClassifyPredictor::ConvertOutputToMXNet( void *src_ptr, void *dest_ptr, int out_index) { auto &real_shape = bpu_model_->outputs[out_index].shape; auto elem_size = 4; // TODO(zhe.sun) 是否可判断float auto shift = bpu_model_->outputs[out_index].shifts; uint32_t dst_n_stride = 2 * elem_size; uint32_t dst_h_stride = 2 * elem_size; uint32_t dst_w_stride = 2 * elem_size; uint32_t src_n_stride = 8 * elem_size; uint32_t src_h_stride = 8 * elem_size; uint32_t src_w_stride = 8 * elem_size; float tmp_float_value; int32_t tmp_int32_value; for (int nn = 0; nn < real_shape.d[0]; nn++) { void *cur_n_dst = reinterpret_cast<int8_t *>(dest_ptr) + nn * dst_n_stride; void *cur_n_src = reinterpret_cast<int8_t *>(src_ptr) + nn * src_n_stride; for (int hh = 0; hh < real_shape.d[1]; hh++) { void *cur_h_dst = reinterpret_cast<int8_t *>(cur_n_dst) + hh * dst_h_stride; void *cur_h_src = reinterpret_cast<int8_t *>(cur_n_src) + hh * src_h_stride; for (int ww = 0; ww < real_shape.d[2]; ww++) { void *cur_w_dst = reinterpret_cast<int8_t *>(cur_h_dst) + ww * dst_w_stride; void *cur_w_src = reinterpret_cast<int8_t *>(cur_h_src) + ww * src_w_stride; for (int cc = 0; cc < real_shape.d[3]; cc++) { void *cur_c_dst = reinterpret_cast<int8_t *>(cur_w_dst) + cc * elem_size; void *cur_c_src = reinterpret_cast<int8_t *>(cur_w_src) + cc * elem_size; if (elem_size == 4) { tmp_int32_value = *(reinterpret_cast<int32_t *>(cur_c_src)); tmp_float_value = GetFloatByInt(tmp_int32_value, shift[cc]); *(reinterpret_cast<float *>(cur_c_dst)) = tmp_float_value; } else { *(reinterpret_cast<int8_t *>(cur_c_dst)) = *(reinterpret_cast<int8_t *>(cur_c_src)); } } } } } } float ClassifyPredictor::GetFloatByInt(int32_t value, uint32_t shift) { float ret_x = value; if (value != 0) { int *ix = reinterpret_cast<int *>(&ret_x); (*ix) -= shift * 0x00800000; } return ret_x; } #endif } // namespace xstream
; A200862: G.f.: (1-2*x^2)/(1-2*x-5*x^2+9*x^3). ; Submitted by Jon Maiga ; 1,2,7,15,47,106,312,731,2068,4983,13727,33757,91302,227846,608389,1534290,4059911,10315771,27122487,69284630,181339756,465000279,1213137668,3119218927,8119123683,20916102989,54354854050,140218109898,363965563145,939827989330,2437520805303,6298491488951,16326135100447,42207040397922,109358332897520,282816651880627,732561604667556,1894981472660567,4907421101733271,12696695124761373,32875662504243998,85068010716695422,220244077831758477,569947246708798082,1475502786126129751,3818545105310423619 mov $1,3 lpb $0 sub $0,1 mul $3,3 add $1,$3 mul $3,2 sub $3,$4 mov $2,$3 mov $4,3 add $5,3 mov $3,$5 add $4,$1 add $5,$2 lpe mov $0,$5 div $0,3 add $0,1
;------------------------------------------------------------------------------ ;* ;* Copyright 2006 - 2007, Intel Corporation ;* All rights reserved. This program and the accompanying materials ;* are licensed and made available under the terms and conditions of the BSD License ;* which accompanies this distribution. The full text of the license may be found at ;* http://opensource.org/licenses/bsd-license.php ;* ;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, ;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. ;* ;* start.asm ;* ;* Abstract: ;* ;------------------------------------------------------------------------------ .model small .stack .486p .code FAT_DIRECTORY_ENTRY_SIZE EQU 020h FAT_DIRECTORY_ENTRY_SHIFT EQU 5 BLOCK_SIZE EQU 0200h BLOCK_MASK EQU 01ffh BLOCK_SHIFT EQU 9 org 0h Ia32Jump: jmp BootSectorEntryPoint ; JMP inst - 3 bytes nop OemId db "INTEL " ; OemId - 8 bytes SectorSize dw 0 ; Sector Size - 16 bits SectorsPerCluster db 0 ; Sector Per Cluster - 8 bits ReservedSectors dw 0 ; Reserved Sectors - 16 bits NoFats db 0 ; Number of FATs - 8 bits RootEntries dw 0 ; Root Entries - 16 bits Sectors dw 0 ; Number of Sectors - 16 bits Media db 0 ; Media - 8 bits - ignored SectorsPerFat dw 0 ; Sectors Per FAT - 16 bits SectorsPerTrack dw 0 ; Sectors Per Track - 16 bits - ignored Heads dw 0 ; Heads - 16 bits - ignored HiddenSectors dd 0 ; Hidden Sectors - 32 bits - ignored LargeSectors dd 0 ; Large Sectors - 32 bits PhysicalDrive db 0 ; PhysicalDriveNumber - 8 bits - ignored CurrentHead db 0 ; Current Head - 8 bits Signature db 0 ; Signature - 8 bits - ignored VolId db " " ; Volume Serial Number- 4 bytes FatLabel db " " ; Label - 11 bytes SystemId db "FAT12 " ; SystemId - 8 bytes BootSectorEntryPoint: ASSUME ds:@code ASSUME ss:@code ; ds = 1000, es = 2000 + x (size of first cluster >> 4) ; cx = Start Cluster of EfiLdr ; dx = Start Cluster of Efivar.bin ; Re use the BPB data stored in Boot Sector mov bp,07c00h push cx ; Read Efivar.bin ; 1000:dx = DirectoryEntry of Efivar.bin -> BS.com has filled already mov ax,01900h mov es,ax test dx,dx jnz CheckVarStoreSize mov al,1 NoVarStore: push es ; Set the 5th byte start @ 0:19000 to non-zero indicating we should init var store header in DxeIpl mov byte ptr es:[4],al jmp SaveVolumeId CheckVarStoreSize: mov di,dx cmp dword ptr ds:[di+2], 04000h mov al,2 jne NoVarStore LoadVarStore: mov al,0 mov byte ptr es:[4],al mov cx,word ptr[di] ; ES:DI = 1500:0 xor di,di push es mov ax,01500h mov es,ax call ReadFile SaveVolumeId: pop es mov ax,word ptr [bp+VolId] mov word ptr es:[0],ax ; Save Volume Id to 0:19000. we will find the correct volume according to this VolumeId mov ax,word ptr [bp+VolId+2] mov word ptr es:[2],ax ; Read Efildr pop cx ; cx = Start Cluster of Efildr -> BS.com has filled already ; ES:DI = 2000:0, first cluster will be read again xor di,di ; di = 0 mov ax,02000h mov es,ax call ReadFile mov ax,cs mov word ptr cs:[JumpSegment],ax JumpFarInstruction: db 0eah JumpOffset: dw 0200h JumpSegment: dw 2000h ; **************************************************************************** ; ReadFile ; ; Arguments: ; CX = Start Cluster of File ; ES:DI = Buffer to store file content read from disk ; ; Return: ; (ES << 4 + DI) = end of file content Buffer ; ; **************************************************************************** ReadFile: ; si = NumberOfClusters ; cx = ClusterNumber ; dx = CachedFatSectorNumber ; ds:0000 = CacheFatSectorBuffer ; es:di = Buffer to load file ; bx = NextClusterNumber pusha mov si,1 ; NumberOfClusters = 1 push cx ; Push Start Cluster onto stack mov dx,0fffh ; CachedFatSectorNumber = 0xfff FatChainLoop: mov ax,cx ; ax = ClusterNumber and ax,0ff8h ; ax = ax & 0xff8 cmp ax,0ff8h ; See if this is the last cluster je FoundLastCluster ; Jump if last cluster found mov ax,cx ; ax = ClusterNumber shl ax,1 ; ax = ClusterNumber * 2 add ax,cx ; ax = ClusterNumber * 2 + ClusterNumber = ClusterNumber * 3 shr ax,1 ; FatOffset = ClusterNumber*3 / 2 push si ; Save si mov si,ax ; si = FatOffset shr ax,BLOCK_SHIFT ; ax = FatOffset >> BLOCK_SHIFT add ax,word ptr [bp+ReservedSectors] ; ax = FatSectorNumber = ReservedSectors + (FatOffset >> BLOCK_OFFSET) and si,BLOCK_MASK ; si = FatOffset & BLOCK_MASK cmp ax,dx ; Compare FatSectorNumber to CachedFatSectorNumber je SkipFatRead mov bx,2 push es push ds pop es call ReadBlocks ; Read 2 blocks starting at AX storing at ES:DI pop es mov dx,ax ; CachedFatSectorNumber = FatSectorNumber SkipFatRead: mov bx,word ptr [si] ; bx = NextClusterNumber mov ax,cx ; ax = ClusterNumber and ax,1 ; See if this is an odd cluster number je EvenFatEntry shr bx,4 ; NextClusterNumber = NextClusterNumber >> 4 EvenFatEntry: and bx,0fffh ; Strip upper 4 bits of NextClusterNumber pop si ; Restore si dec bx ; bx = NextClusterNumber - 1 cmp bx,cx ; See if (NextClusterNumber-1)==ClusterNumber jne ReadClusters inc bx ; bx = NextClusterNumber inc si ; NumberOfClusters++ mov cx,bx ; ClusterNumber = NextClusterNumber jmp FatChainLoop ReadClusters: inc bx pop ax ; ax = StartCluster push bx ; StartCluster = NextClusterNumber mov cx,bx ; ClusterNumber = NextClusterNumber sub ax,2 ; ax = StartCluster - 2 xor bh,bh mov bl,byte ptr [bp+SectorsPerCluster] ; bx = SectorsPerCluster mul bx ; ax = (StartCluster - 2) * SectorsPerCluster add ax, word ptr [bp] ; ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster push ax ; save start sector mov ax,si ; ax = NumberOfClusters mul bx ; ax = NumberOfClusters * SectorsPerCluster mov bx,ax ; bx = Number of Sectors pop ax ; ax = Start Sector call ReadBlocks mov si,1 ; NumberOfClusters = 1 jmp FatChainLoop FoundLastCluster: pop cx popa ret ; **************************************************************************** ; ReadBlocks - Reads a set of blocks from a block device ; ; AX = Start LBA ; BX = Number of Blocks to Read ; ES:DI = Buffer to store sectors read from disk ; **************************************************************************** ; cx = Blocks ; bx = NumberOfBlocks ; si = StartLBA ReadBlocks: pusha add eax,dword ptr [bp+LBAOffsetForBootSector] ; Add LBAOffsetForBootSector to Start LBA add eax,dword ptr [bp+HiddenSectors] ; Add HiddenSectors to Start LBA mov esi,eax ; esi = Start LBA mov cx,bx ; cx = Number of blocks to read ReadCylinderLoop: mov bp,07bfch ; bp = 0x7bfc mov eax,esi ; eax = Start LBA xor edx,edx ; edx = 0 movzx ebx,word ptr [bp] ; bx = MaxSector div ebx ; ax = StartLBA / MaxSector inc dx ; dx = (StartLBA % MaxSector) + 1 mov bx,word ptr [bp] ; bx = MaxSector sub bx,dx ; bx = MaxSector - Sector inc bx ; bx = MaxSector - Sector + 1 cmp cx,bx ; Compare (Blocks) to (MaxSector - Sector + 1) jg LimitTransfer mov bx,cx ; bx = Blocks LimitTransfer: push ax ; save ax mov ax,es ; ax = es shr ax,(BLOCK_SHIFT-4) ; ax = Number of blocks into mem system and ax,07fh ; ax = Number of blocks into current seg add ax,bx ; ax = End Block number of transfer cmp ax,080h ; See if it crosses a 64K boundry jle NotCrossing64KBoundry ; Branch if not crossing 64K boundry sub ax,080h ; ax = Number of blocks past 64K boundry sub bx,ax ; Decrease transfer size by block overage NotCrossing64KBoundry: pop ax ; restore ax push cx mov cl,dl ; cl = (StartLBA % MaxSector) + 1 = Sector xor dx,dx ; dx = 0 div word ptr [bp+2] ; ax = ax / (MaxHead + 1) = Cylinder ; dx = ax % (MaxHead + 1) = Head push bx ; Save number of blocks to transfer mov dh,dl ; dh = Head mov bp,07c00h ; bp = 0x7c00 mov dl,byte ptr [bp+PhysicalDrive] ; dl = Drive Number mov ch,al ; ch = Cylinder mov al,bl ; al = Blocks mov ah,2 ; ah = Function 2 mov bx,di ; es:bx = Buffer address int 013h jc DiskError pop bx pop cx movzx ebx,bx add esi,ebx ; StartLBA = StartLBA + NumberOfBlocks sub cx,bx ; Blocks = Blocks - NumberOfBlocks mov ax,es shl bx,(BLOCK_SHIFT-4) add ax,bx mov es,ax ; es:di = es:di + NumberOfBlocks*BLOCK_SIZE cmp cx,0 jne ReadCylinderLoop popa ret DiskError: push cs pop ds lea si, [ErrorString] mov cx, 7 jmp PrintStringAndHalt PrintStringAndHalt: mov ax,0b800h mov es,ax mov di,160 rep movsw Halt: jmp Halt ErrorString: db 'S', 0ch, 'E', 0ch, 'r', 0ch, 'r', 0ch, 'o', 0ch, 'r', 0ch, '!', 0ch org 01fah LBAOffsetForBootSector: dd 0h org 01feh dw 0aa55h ;****************************************************************************** ;****************************************************************************** ;****************************************************************************** DELAY_PORT equ 0edh ; Port to use for 1uS delay KBD_CONTROL_PORT equ 060h ; 8042 control port KBD_STATUS_PORT equ 064h ; 8042 status port WRITE_DATA_PORT_CMD equ 0d1h ; 8042 command to write the data port ENABLE_A20_CMD equ 0dfh ; 8042 command to enable A20 org 200h jmp start Em64String: db 'E', 0ch, 'm', 0ch, '6', 0ch, '4', 0ch, 'T', 0ch, ' ', 0ch, 'U', 0ch, 'n', 0ch, 's', 0ch, 'u', 0ch, 'p', 0ch, 'p', 0ch, 'o', 0ch, 'r', 0ch, 't', 0ch, 'e', 0ch, 'd', 0ch, '!', 0ch start: mov ax,cs mov ds,ax mov es,ax mov ss,ax mov sp,MyStack ; mov ax,0b800h ; mov es,ax ; mov byte ptr es:[160],'a' ; mov ax,cs ; mov es,ax mov ebx,0 lea edi,MemoryMap MemMapLoop: mov eax,0e820h mov ecx,20 mov edx,'SMAP' int 15h jc MemMapDone add edi,20 cmp ebx,0 je MemMapDone jmp MemMapLoop MemMapDone: lea eax,MemoryMap sub edi,eax ; Get the address of the memory map mov dword ptr [MemoryMapSize],edi ; Save the size of the memory map xor ebx,ebx mov bx,cs ; BX=segment shl ebx,4 ; BX="linear" address of segment base lea eax,[GDT_BASE + ebx] ; EAX=PHYSICAL address of gdt mov dword ptr [gdtr + 2],eax ; Put address of gdt into the gdtr lea eax,[IDT_BASE + ebx] ; EAX=PHYSICAL address of idt mov dword ptr [idtr + 2],eax ; Put address of idt into the idtr lea edx,[MemoryMapSize + ebx] ; Physical base address of the memory map add ebx,01000h ; Source of EFI32 mov dword ptr [JUMP+2],ebx add ebx,01000h mov esi,ebx ; Source of EFILDR32 ; mov ax,0b800h ; mov es,ax ; mov byte ptr es:[162],'b' ; mov ax,cs ; mov es,ax ; ; Enable A20 Gate ; mov ax,2401h ; Enable A20 Gate int 15h jnc A20GateEnabled ; Jump if it suceeded ; ; If INT 15 Function 2401 is not supported, then attempt to Enable A20 manually. ; call Empty8042InputBuffer ; Empty the Input Buffer on the 8042 controller jnz Timeout8042 ; Jump if the 8042 timed out out DELAY_PORT,ax ; Delay 1 uS mov al,WRITE_DATA_PORT_CMD ; 8042 cmd to write output port out KBD_STATUS_PORT,al ; Send command to the 8042 call Empty8042InputBuffer ; Empty the Input Buffer on the 8042 controller jnz Timeout8042 ; Jump if the 8042 timed out mov al,ENABLE_A20_CMD ; gate address bit 20 on out KBD_CONTROL_PORT,al ; Send command to thre 8042 call Empty8042InputBuffer ; Empty the Input Buffer on the 8042 controller mov cx,25 ; Delay 25 uS for the command to complete on the 8042 Delay25uS: out DELAY_PORT,ax ; Delay 1 uS loop Delay25uS Timeout8042: A20GateEnabled: ; ; DISABLE INTERRUPTS - Entering Protected Mode ; cli ; mov ax,0b800h ; mov es,ax ; mov byte ptr es:[164],'c' ; mov ax,cs ; mov es,ax db 66h lgdt fword ptr [gdtr] db 66h lidt fword ptr [idtr] mov eax,cr0 or al,1 mov cr0,eax mov eax,0008h ; Flat data descriptor mov ebp,000400000h ; Destination of EFILDR32 mov ebx,000070000h ; Length of copy JUMP: ; jmp far 0010:00020000 db 066h db 0eah dd 000020000h dw 00010h Empty8042InputBuffer: mov cx,0 Empty8042Loop: out DELAY_PORT,ax ; Delay 1us in al,KBD_STATUS_PORT ; Read the 8042 Status Port and al,02h ; Check the Input Buffer Full Flag loopnz Empty8042Loop ; Loop until the input buffer is empty or a timout of 65536 uS ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; data ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; align 02h gdtr dw GDT_END - GDT_BASE - 1 ; GDT limit dd 0 ; (GDT base gets set above) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; global descriptor table (GDT) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; align 02h public GDT_BASE GDT_BASE: ; null descriptor NULL_SEL equ $-GDT_BASE dw 0 ; limit 15:0 dw 0 ; base 15:0 db 0 ; base 23:16 db 0 ; type db 0 ; limit 19:16, flags db 0 ; base 31:24 ; linear data segment descriptor LINEAR_SEL equ $-GDT_BASE dw 0FFFFh ; limit 0xFFFFF dw 0 ; base 0 db 0 db 092h ; present, ring 0, data, expand-up, writable db 0CFh ; page-granular, 32-bit db 0 ; linear code segment descriptor LINEAR_CODE_SEL equ $-GDT_BASE dw 0FFFFh ; limit 0xFFFFF dw 0 ; base 0 db 0 db 09Ah ; present, ring 0, data, expand-up, writable db 0CFh ; page-granular, 32-bit db 0 ; system data segment descriptor SYS_DATA_SEL equ $-GDT_BASE dw 0FFFFh ; limit 0xFFFFF dw 0 ; base 0 db 0 db 092h ; present, ring 0, data, expand-up, writable db 0CFh ; page-granular, 32-bit db 0 ; system code segment descriptor SYS_CODE_SEL equ $-GDT_BASE dw 0FFFFh ; limit 0xFFFFF dw 0 ; base 0 db 0 db 09Ah ; present, ring 0, data, expand-up, writable db 0CFh ; page-granular, 32-bit db 0 ; spare segment descriptor SPARE3_SEL equ $-GDT_BASE dw 0 ; limit 0xFFFFF dw 0 ; base 0 db 0 db 0 ; present, ring 0, data, expand-up, writable db 0 ; page-granular, 32-bit db 0 ; spare segment descriptor SPARE4_SEL equ $-GDT_BASE dw 0 ; limit 0xFFFFF dw 0 ; base 0 db 0 db 0 ; present, ring 0, data, expand-up, writable db 0 ; page-granular, 32-bit db 0 ; spare segment descriptor SPARE5_SEL equ $-GDT_BASE dw 0 ; limit 0xFFFFF dw 0 ; base 0 db 0 db 0 ; present, ring 0, data, expand-up, writable db 0 ; page-granular, 32-bit db 0 GDT_END: align 02h idtr dw IDT_END - IDT_BASE - 1 ; IDT limit dd 0 ; (IDT base gets set above) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; interrupt descriptor table (IDT) ; ; Note: The hardware IRQ's specified in this table are the normal PC/AT IRQ ; mappings. This implementation only uses the system timer and all other ; IRQs will remain masked. The descriptors for vectors 33+ are provided ; for convenience. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;idt_tag db "IDT",0 align 02h public IDT_BASE IDT_BASE: ; divide by zero (INT 0) DIV_ZERO_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; type = 386 interrupt gate, present dw 0 ; offset 31:16 ; debug exception (INT 1) DEBUG_EXCEPT_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; type = 386 interrupt gate, present dw 0 ; offset 31:16 ; NMI (INT 2) NMI_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; type = 386 interrupt gate, present dw 0 ; offset 31:16 ; soft breakpoint (INT 3) BREAKPOINT_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; type = 386 interrupt gate, present dw 0 ; offset 31:16 ; overflow (INT 4) OVERFLOW_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; type = 386 interrupt gate, present dw 0 ; offset 31:16 ; bounds check (INT 5) BOUNDS_CHECK_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; type = 386 interrupt gate, present dw 0 ; offset 31:16 ; invalid opcode (INT 6) INVALID_OPCODE_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; type = 386 interrupt gate, present dw 0 ; offset 31:16 ; device not available (INT 7) DEV_NOT_AVAIL_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; type = 386 interrupt gate, present dw 0 ; offset 31:16 ; double fault (INT 8) DOUBLE_FAULT_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; type = 386 interrupt gate, present dw 0 ; offset 31:16 ; Coprocessor segment overrun - reserved (INT 9) RSVD_INTR_SEL1 equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; type = 386 interrupt gate, present dw 0 ; offset 31:16 ; invalid TSS (INT 0ah) INVALID_TSS_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; type = 386 interrupt gate, present dw 0 ; offset 31:16 ; segment not present (INT 0bh) SEG_NOT_PRESENT_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; type = 386 interrupt gate, present dw 0 ; offset 31:16 ; stack fault (INT 0ch) STACK_FAULT_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; type = 386 interrupt gate, present dw 0 ; offset 31:16 ; general protection (INT 0dh) GP_FAULT_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; type = 386 interrupt gate, present dw 0 ; offset 31:16 ; page fault (INT 0eh) PAGE_FAULT_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; type = 386 interrupt gate, present dw 0 ; offset 31:16 ; Intel reserved - do not use (INT 0fh) RSVD_INTR_SEL2 equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; type = 386 interrupt gate, present dw 0 ; offset 31:16 ; floating point error (INT 10h) FLT_POINT_ERR_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; type = 386 interrupt gate, present dw 0 ; offset 31:16 ; alignment check (INT 11h) ALIGNMENT_CHECK_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; (10001110)type = 386 interrupt gate, present dw 0 ; offset 31:16 ; machine check (INT 12h) MACHINE_CHECK_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; (10001110)type = 386 interrupt gate, present dw 0 ; offset 31:16 ; SIMD floating-point exception (INT 13h) SIMD_EXCEPTION_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; (10001110)type = 386 interrupt gate, present dw 0 ; offset 31:16 ; 85 unspecified descriptors, First 12 of them are reserved, the rest are avail db (85 * 8) dup(0) ; IRQ 0 (System timer) - (INT 68h) IRQ0_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; (10001110)type = 386 interrupt gate, present dw 0 ; offset 31:16 ; IRQ 1 (8042 Keyboard controller) - (INT 69h) IRQ1_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; (10001110)type = 386 interrupt gate, present dw 0 ; offset 31:16 ; Reserved - IRQ 2 redirect (IRQ 2) - DO NOT USE!!! - (INT 6ah) IRQ2_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; (10001110)type = 386 interrupt gate, present dw 0 ; offset 31:16 ; IRQ 3 (COM 2) - (INT 6bh) IRQ3_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; (10001110)type = 386 interrupt gate, present dw 0 ; offset 31:16 ; IRQ 4 (COM 1) - (INT 6ch) IRQ4_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; (10001110)type = 386 interrupt gate, present dw 0 ; offset 31:16 ; IRQ 5 (LPT 2) - (INT 6dh) IRQ5_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; (10001110)type = 386 interrupt gate, present dw 0 ; offset 31:16 ; IRQ 6 (Floppy controller) - (INT 6eh) IRQ6_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; (10001110)type = 386 interrupt gate, present dw 0 ; offset 31:16 ; IRQ 7 (LPT 1) - (INT 6fh) IRQ7_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; (10001110)type = 386 interrupt gate, present dw 0 ; offset 31:16 ; IRQ 8 (RTC Alarm) - (INT 70h) IRQ8_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; (10001110)type = 386 interrupt gate, present dw 0 ; offset 31:16 ; IRQ 9 - (INT 71h) IRQ9_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; (10001110)type = 386 interrupt gate, present dw 0 ; offset 31:16 ; IRQ 10 - (INT 72h) IRQ10_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; (10001110)type = 386 interrupt gate, present dw 0 ; offset 31:16 ; IRQ 11 - (INT 73h) IRQ11_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; (10001110)type = 386 interrupt gate, present dw 0 ; offset 31:16 ; IRQ 12 (PS/2 mouse) - (INT 74h) IRQ12_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; (10001110)type = 386 interrupt gate, present dw 0 ; offset 31:16 ; IRQ 13 (Floating point error) - (INT 75h) IRQ13_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; (10001110)type = 386 interrupt gate, present dw 0 ; offset 31:16 ; IRQ 14 (Secondary IDE) - (INT 76h) IRQ14_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; (10001110)type = 386 interrupt gate, present dw 0 ; offset 31:16 ; IRQ 15 (Primary IDE) - (INT 77h) IRQ15_SEL equ $-IDT_BASE dw 0 ; offset 15:0 dw SYS_CODE_SEL ; selector 15:0 db 0 ; 0 for interrupt gate db 0eh OR 80h ; (10001110)type = 386 interrupt gate, present dw 0 ; offset 31:16 IDT_END: align 02h MemoryMapSize dd 0 MemoryMap dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 dd 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 org 0fe0h MyStack: ; below is the pieces of the IVT that is used to redirect INT 68h - 6fh ; back to INT 08h - 0fh when in real mode... It is 'org'ed to a ; known low address (20f00) so it can be set up by PlMapIrqToVect in ; 8259.c int 8 iret int 9 iret int 10 iret int 11 iret int 12 iret int 13 iret int 14 iret int 15 iret org 0ffeh BlockSignature: dw 0aa55h end
#include "sudoku.h" #include "mainsudoku.h" extern MainSudoku *pt_w; void Sudoku::exibir() const{ for(int i=0; i<9; i++) for(int j=0; j<9; j++){ pt_w->exibirCelulaAtual(i,j,this->at(i,j)); } } void Sudoku::exibir_origem() const{ for(int i=0; i<9; i++) for(int j=0; j<9; j++){ pt_w->exibirCelulaInicial(i,j,this->at(i,j)); } } void Sudoku::exibir_andamento(unsigned Ntab_testados, unsigned Ntab_gerados, unsigned Ntab_analisar) const{ pt_w->exibirAndamento(Ntab_testados,Ntab_gerados,Ntab_analisar); }
; A083297: a(n) = (4*4^n + (-6)^n)/5. ; Submitted by Jon Maiga ; 1,2,20,8,464,-736,12608,-42880,388352,-1805824,12932096,-69203968,448778240,-2558451712,15887581184,-93178003456,567657955328,-3371587993600,20366966915072,-121652045676544,732111297314816,-4383871690866688,26338414517288960,-157889749615378432,947901447645691904,-5685156886060466176,34119948515617538048,-204683662296686264320,1228246088968193441792,-7368900073056857227264,44215706281350357057536,-265285014316065287569408,1591746979384539144519680,-9550334302354645190705152 mov $1,-6 pow $1,$0 mov $2,4 pow $2,$0 mul $2,4 add $1,$2 mov $0,$1 div $0,5
/* * All Video Processing kernels * Copyright © <2010>, Intel Corporation. * * This program is licensed under the terms and conditions of the * Eclipse Public License (EPL), version 1.0. The full text of the EPL is at * http://www.opensource.org/licenses/eclipse-1.0.php. * */ //---------- PL3_AVS_IEF_Unpack_8x8.asm ---------- // Move 1st 8x8 words of Y to dest GRF at lower 8 words of each RGF. $for(0; <8/2; 1) { mov (8) uwDEST_Y(%1*2)<1> ubAVS_RESPONSE(%1,1)<16;4,2> // Copy high byte in a word mov (8) uwDEST_Y(%1*2+1)<1> ubAVS_RESPONSE(%1,8+1)<16;4,2> // Copy high byte in a word } // Move 8x8 words of U to dest GRF $for(0; <8/2; 1) { mov (8) uwDEST_U(%1)<1> ubAVS_RESPONSE(%1+4,1)<16;4,2> // Copy high byte in a word mov (8) uwDEST_U(%1,8)<1> ubAVS_RESPONSE(%1+4,8+1)<16;4,2> // Copy high byte in a word } // Move 8x8 words of V to dest GRF $for(0; <8/2; 1) { mov (8) uwDEST_V(%1)<1> ubAVS_RESPONSE(%1+8,1)<16;4,2> // Copy high byte in a word mov (8) uwDEST_V(%1,8)<1> ubAVS_RESPONSE(%1+8,8+1)<16;4,2> // Copy high byte in a word } // Move 2nd 8x8 words of Y to dest GRF at higher 8 words of each RGF. $for(0; <8/2; 1) { mov (8) uwDEST_Y(%1*2,8)<1> ubAVS_RESPONSE(%1+12,1)<16;4,2> // Copy high byte in a word mov (8) uwDEST_Y(%1*2+1,8)<1> ubAVS_RESPONSE(%1+12,8+1)<16;4,2> // Copy high byte in a word } //------------------------------------------------------------------------------ // Re-define new # of lines #undef nUV_NUM_OF_ROWS #undef nY_NUM_OF_ROWS #define nY_NUM_OF_ROWS 8 #define nUV_NUM_OF_ROWS 8
/*************************************************************************/ /* visual_script_func_nodes.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* 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. */ /*************************************************************************/ #include "visual_script_func_nodes.h" #include "core/engine.h" #include "core/io/resource_loader.h" #include "core/os/os.h" #include "scene/main/node.h" #include "scene/main/scene_tree.h" #include "visual_script_nodes.h" ////////////////////////////////////////// ////////////////CALL////////////////////// ////////////////////////////////////////// int VisualScriptFunctionCall::get_output_sequence_port_count() const { if ((method_cache.flags & METHOD_FLAG_CONST && call_mode != CALL_MODE_INSTANCE) || (call_mode == CALL_MODE_BASIC_TYPE && Variant::is_method_const(basic_type, function))) { return 0; } else { return 1; } } bool VisualScriptFunctionCall::has_input_sequence_port() const { return !((method_cache.flags & METHOD_FLAG_CONST && call_mode != CALL_MODE_INSTANCE) || (call_mode == CALL_MODE_BASIC_TYPE && Variant::is_method_const(basic_type, function))); } #ifdef TOOLS_ENABLED static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) { if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene) { return nullptr; } Ref<Script> scr = p_current_node->get_script(); if (scr.is_valid() && scr == script) { return p_current_node; } for (int i = 0; i < p_current_node->get_child_count(); i++) { Node *n = _find_script_node(p_edited_scene, p_current_node->get_child(i), script); if (n) { return n; } } return nullptr; } #endif Node *VisualScriptFunctionCall::_get_base_node() const { #ifdef TOOLS_ENABLED Ref<Script> script = get_visual_script(); if (!script.is_valid()) { return nullptr; } MainLoop *main_loop = OS::get_singleton()->get_main_loop(); SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop); if (!scene_tree) { return nullptr; } Node *edited_scene = scene_tree->get_edited_scene_root(); if (!edited_scene) { return nullptr; } Node *script_node = _find_script_node(edited_scene, edited_scene, script); if (!script_node) { return nullptr; } if (!script_node->has_node(base_path)) { return nullptr; } Node *path_to = script_node->get_node(base_path); return path_to; #else return NULL; #endif } StringName VisualScriptFunctionCall::_get_base_type() const { if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) { return get_visual_script()->get_instance_base_type(); } else if (call_mode == CALL_MODE_NODE_PATH && get_visual_script().is_valid()) { Node *path = _get_base_node(); if (path) { return path->get_class(); } } return base_type; } int VisualScriptFunctionCall::get_input_value_port_count() const { if (call_mode == CALL_MODE_BASIC_TYPE) { Vector<Variant::Type> types = Variant::get_method_argument_types(basic_type, function); return types.size() + (rpc_call_mode >= RPC_RELIABLE_TO_ID ? 1 : 0) + 1; } else { MethodBind *mb = ClassDB::get_method(_get_base_type(), function); if (mb) { int defaulted_args = mb->get_argument_count() < use_default_args ? mb->get_argument_count() : use_default_args; return mb->get_argument_count() + (call_mode == CALL_MODE_INSTANCE ? 1 : 0) + (rpc_call_mode >= RPC_RELIABLE_TO_ID ? 1 : 0) - defaulted_args; } int defaulted_args = method_cache.arguments.size() < use_default_args ? method_cache.arguments.size() : use_default_args; return method_cache.arguments.size() + (call_mode == CALL_MODE_INSTANCE ? 1 : 0) + (rpc_call_mode >= RPC_RELIABLE_TO_ID ? 1 : 0) - defaulted_args; } } int VisualScriptFunctionCall::get_output_value_port_count() const { if (call_mode == CALL_MODE_BASIC_TYPE) { bool returns = false; Variant::get_method_return_type(basic_type, function, &returns); return returns ? 1 : 0; } else { int ret; MethodBind *mb = ClassDB::get_method(_get_base_type(), function); if (mb) { ret = mb->has_return() ? 1 : 0; } else { ret = 1; //it is assumed that script always returns something } if (call_mode == CALL_MODE_INSTANCE) { ret++; } return ret; } } String VisualScriptFunctionCall::get_output_sequence_port_text(int p_port) const { return String(); } PropertyInfo VisualScriptFunctionCall::get_input_value_port_info(int p_idx) const { if (call_mode == CALL_MODE_INSTANCE || call_mode == CALL_MODE_BASIC_TYPE) { if (p_idx == 0) { PropertyInfo pi; pi.type = (call_mode == CALL_MODE_INSTANCE ? Variant::OBJECT : basic_type); pi.name = (call_mode == CALL_MODE_INSTANCE ? String("instance") : Variant::get_type_name(basic_type).to_lower()); return pi; } else { p_idx--; } } if (rpc_call_mode >= RPC_RELIABLE_TO_ID) { if (p_idx == 0) { return PropertyInfo(Variant::INT, "peer_id"); } else { p_idx--; } } #ifdef DEBUG_METHODS_ENABLED if (call_mode == CALL_MODE_BASIC_TYPE) { Vector<StringName> names = Variant::get_method_argument_names(basic_type, function); Vector<Variant::Type> types = Variant::get_method_argument_types(basic_type, function); return PropertyInfo(types[p_idx], names[p_idx]); } else { MethodBind *mb = ClassDB::get_method(_get_base_type(), function); if (mb) { return mb->get_argument_info(p_idx); } if (p_idx >= 0 && p_idx < method_cache.arguments.size()) { return method_cache.arguments[p_idx]; } return PropertyInfo(); } #else return PropertyInfo(); #endif } PropertyInfo VisualScriptFunctionCall::get_output_value_port_info(int p_idx) const { #ifdef DEBUG_METHODS_ENABLED if (call_mode == CALL_MODE_BASIC_TYPE) { return PropertyInfo(Variant::get_method_return_type(basic_type, function), ""); } else { if (call_mode == CALL_MODE_INSTANCE) { if (p_idx == 0) { return PropertyInfo(Variant::OBJECT, "pass", PROPERTY_HINT_TYPE_STRING, get_base_type()); } else { p_idx--; } } PropertyInfo ret; /*MethodBind *mb = ClassDB::get_method(_get_base_type(),function); if (mb) { ret = mb->get_argument_info(-1); } else {*/ ret = method_cache.return_val; //} if (call_mode == CALL_MODE_INSTANCE) { ret.name = "return"; } else { ret.name = ""; } return ret; } #else return PropertyInfo(); #endif } String VisualScriptFunctionCall::get_caption() const { return " " + String(function) + "()"; } String VisualScriptFunctionCall::get_text() const { String text; if (call_mode == CALL_MODE_BASIC_TYPE) { text = String("On ") + Variant::get_type_name(basic_type); } else if (call_mode == CALL_MODE_INSTANCE) { text = String("On ") + base_type; } else if (call_mode == CALL_MODE_NODE_PATH) { text = "[" + String(base_path.simplified()) + "]"; } else if (call_mode == CALL_MODE_SELF) { text = "On Self"; } else if (call_mode == CALL_MODE_SINGLETON) { text = String(singleton) + ":" + String(function) + "()"; } if (rpc_call_mode) { text += " RPC"; if (rpc_call_mode == RPC_UNRELIABLE || rpc_call_mode == RPC_UNRELIABLE_TO_ID) { text += " UNREL"; } } return text; } void VisualScriptFunctionCall::set_basic_type(Variant::Type p_type) { if (basic_type == p_type) { return; } basic_type = p_type; _change_notify(); ports_changed_notify(); } Variant::Type VisualScriptFunctionCall::get_basic_type() const { return basic_type; } void VisualScriptFunctionCall::set_base_type(const StringName &p_type) { if (base_type == p_type) { return; } base_type = p_type; _change_notify(); ports_changed_notify(); } StringName VisualScriptFunctionCall::get_base_type() const { return base_type; } void VisualScriptFunctionCall::set_base_script(const String &p_path) { if (base_script == p_path) { return; } base_script = p_path; _change_notify(); ports_changed_notify(); } String VisualScriptFunctionCall::get_base_script() const { return base_script; } void VisualScriptFunctionCall::set_singleton(const StringName &p_type) { if (singleton == p_type) { return; } singleton = p_type; Object *obj = Engine::get_singleton()->get_singleton_object(singleton); if (obj) { base_type = obj->get_class(); } _change_notify(); ports_changed_notify(); } StringName VisualScriptFunctionCall::get_singleton() const { return singleton; } void VisualScriptFunctionCall::_update_method_cache() { StringName type; Ref<Script> script; if (call_mode == CALL_MODE_NODE_PATH) { Node *node = _get_base_node(); if (node) { type = node->get_class(); base_type = type; //cache, too script = node->get_script(); } } else if (call_mode == CALL_MODE_SELF) { if (get_visual_script().is_valid()) { type = get_visual_script()->get_instance_base_type(); base_type = type; //cache, too script = get_visual_script(); } } else if (call_mode == CALL_MODE_SINGLETON) { Object *obj = Engine::get_singleton()->get_singleton_object(singleton); if (obj) { type = obj->get_class(); script = obj->get_script(); } } else if (call_mode == CALL_MODE_INSTANCE) { type = base_type; if (base_script != String()) { if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) { ScriptServer::edit_request_func(base_script); //make sure it's loaded } if (ResourceCache::has(base_script)) { script = Ref<Resource>(ResourceCache::get(base_script)); } else { return; } } } MethodBind *mb = ClassDB::get_method(type, function); if (mb) { use_default_args = mb->get_default_argument_count(); method_cache = MethodInfo(); for (int i = 0; i < mb->get_argument_count(); i++) { #ifdef DEBUG_METHODS_ENABLED method_cache.arguments.push_back(mb->get_argument_info(i)); #else method_cache.arguments.push_back(PropertyInfo()); #endif } if (mb->is_const()) { method_cache.flags |= METHOD_FLAG_CONST; } #ifdef DEBUG_METHODS_ENABLED method_cache.return_val = mb->get_return_info(); #endif if (mb->is_vararg()) { //for vararg just give it 10 arguments (should be enough for most use cases) for (int i = 0; i < 10; i++) { method_cache.arguments.push_back(PropertyInfo(Variant::NIL, "arg" + itos(i))); use_default_args++; } } } else if (script.is_valid() && script->has_method(function)) { method_cache = script->get_method_info(function); use_default_args = method_cache.default_arguments.size(); } } void VisualScriptFunctionCall::set_function(const StringName &p_type) { if (function == p_type) { return; } function = p_type; if (call_mode == CALL_MODE_BASIC_TYPE) { use_default_args = Variant::get_method_default_arguments(basic_type, function).size(); } else { //update all caches _update_method_cache(); } _change_notify(); ports_changed_notify(); } StringName VisualScriptFunctionCall::get_function() const { return function; } void VisualScriptFunctionCall::set_base_path(const NodePath &p_type) { if (base_path == p_type) { return; } base_path = p_type; _change_notify(); ports_changed_notify(); } NodePath VisualScriptFunctionCall::get_base_path() const { return base_path; } void VisualScriptFunctionCall::set_call_mode(CallMode p_mode) { if (call_mode == p_mode) { return; } call_mode = p_mode; _change_notify(); ports_changed_notify(); } VisualScriptFunctionCall::CallMode VisualScriptFunctionCall::get_call_mode() const { return call_mode; } void VisualScriptFunctionCall::set_use_default_args(int p_amount) { if (use_default_args == p_amount) { return; } use_default_args = p_amount; ports_changed_notify(); } void VisualScriptFunctionCall::set_rpc_call_mode(VisualScriptFunctionCall::RPCCallMode p_mode) { if (rpc_call_mode == p_mode) { return; } rpc_call_mode = p_mode; ports_changed_notify(); _change_notify(); } VisualScriptFunctionCall::RPCCallMode VisualScriptFunctionCall::get_rpc_call_mode() const { return rpc_call_mode; } int VisualScriptFunctionCall::get_use_default_args() const { return use_default_args; } void VisualScriptFunctionCall::set_validate(bool p_amount) { validate = p_amount; } bool VisualScriptFunctionCall::get_validate() const { return validate; } void VisualScriptFunctionCall::_set_argument_cache(const Dictionary &p_cache) { //so everything works in case all else fails method_cache = MethodInfo::from_dict(p_cache); } Dictionary VisualScriptFunctionCall::_get_argument_cache() const { return method_cache; } void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const { if (property.name == "base_type") { if (call_mode != CALL_MODE_INSTANCE) { property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL; } } if (property.name == "base_script") { if (call_mode != CALL_MODE_INSTANCE) { property.usage = 0; } } if (property.name == "basic_type") { if (call_mode != CALL_MODE_BASIC_TYPE) { property.usage = 0; } } if (property.name == "singleton") { if (call_mode != CALL_MODE_SINGLETON) { property.usage = 0; } else { List<Engine::Singleton> names; Engine::get_singleton()->get_singletons(&names); property.hint = PROPERTY_HINT_ENUM; String sl; for (List<Engine::Singleton>::Element *E = names.front(); E; E = E->next()) { if (sl != String()) { sl += ","; } sl += E->get().name; } property.hint_string = sl; } } if (property.name == "node_path") { if (call_mode != CALL_MODE_NODE_PATH) { property.usage = 0; } else { Node *bnode = _get_base_node(); if (bnode) { property.hint_string = bnode->get_path(); //convert to loong string } } } if (property.name == "function") { if (call_mode == CALL_MODE_BASIC_TYPE) { property.hint = PROPERTY_HINT_METHOD_OF_VARIANT_TYPE; property.hint_string = Variant::get_type_name(basic_type); } else if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) { property.hint = PROPERTY_HINT_METHOD_OF_SCRIPT; property.hint_string = itos(get_visual_script()->get_instance_id()); } else if (call_mode == CALL_MODE_SINGLETON) { Object *obj = Engine::get_singleton()->get_singleton_object(singleton); if (obj) { property.hint = PROPERTY_HINT_METHOD_OF_INSTANCE; property.hint_string = itos(obj->get_instance_id()); } else { property.hint = PROPERTY_HINT_METHOD_OF_BASE_TYPE; property.hint_string = base_type; //should be cached } } else if (call_mode == CALL_MODE_INSTANCE) { property.hint = PROPERTY_HINT_METHOD_OF_BASE_TYPE; property.hint_string = base_type; if (base_script != String()) { if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) { ScriptServer::edit_request_func(base_script); //make sure it's loaded } if (ResourceCache::has(base_script)) { Ref<Script> script = Ref<Resource>(ResourceCache::get(base_script)); if (script.is_valid()) { property.hint = PROPERTY_HINT_METHOD_OF_SCRIPT; property.hint_string = itos(script->get_instance_id()); } } } } else if (call_mode == CALL_MODE_NODE_PATH) { Node *node = _get_base_node(); if (node) { property.hint = PROPERTY_HINT_METHOD_OF_INSTANCE; property.hint_string = itos(node->get_instance_id()); } else { property.hint = PROPERTY_HINT_METHOD_OF_BASE_TYPE; property.hint_string = get_base_type(); } } } if (property.name == "use_default_args") { property.hint = PROPERTY_HINT_RANGE; int mc = 0; if (call_mode == CALL_MODE_BASIC_TYPE) { mc = Variant::get_method_default_arguments(basic_type, function).size(); } else { MethodBind *mb = ClassDB::get_method(_get_base_type(), function); if (mb) { mc = mb->get_default_argument_count(); } } if (mc == 0) { property.usage = 0; //do not show } else { property.hint_string = "0," + itos(mc) + ",1"; } } if (property.name == "rpc_call_mode") { if (call_mode == CALL_MODE_BASIC_TYPE) { property.usage = 0; } } } void VisualScriptFunctionCall::_bind_methods() { ClassDB::bind_method(D_METHOD("set_base_type", "base_type"), &VisualScriptFunctionCall::set_base_type); ClassDB::bind_method(D_METHOD("get_base_type"), &VisualScriptFunctionCall::get_base_type); ClassDB::bind_method(D_METHOD("set_base_script", "base_script"), &VisualScriptFunctionCall::set_base_script); ClassDB::bind_method(D_METHOD("get_base_script"), &VisualScriptFunctionCall::get_base_script); ClassDB::bind_method(D_METHOD("set_basic_type", "basic_type"), &VisualScriptFunctionCall::set_basic_type); ClassDB::bind_method(D_METHOD("get_basic_type"), &VisualScriptFunctionCall::get_basic_type); ClassDB::bind_method(D_METHOD("set_singleton", "singleton"), &VisualScriptFunctionCall::set_singleton); ClassDB::bind_method(D_METHOD("get_singleton"), &VisualScriptFunctionCall::get_singleton); ClassDB::bind_method(D_METHOD("set_function", "function"), &VisualScriptFunctionCall::set_function); ClassDB::bind_method(D_METHOD("get_function"), &VisualScriptFunctionCall::get_function); ClassDB::bind_method(D_METHOD("set_call_mode", "mode"), &VisualScriptFunctionCall::set_call_mode); ClassDB::bind_method(D_METHOD("get_call_mode"), &VisualScriptFunctionCall::get_call_mode); ClassDB::bind_method(D_METHOD("set_base_path", "base_path"), &VisualScriptFunctionCall::set_base_path); ClassDB::bind_method(D_METHOD("get_base_path"), &VisualScriptFunctionCall::get_base_path); ClassDB::bind_method(D_METHOD("set_use_default_args", "amount"), &VisualScriptFunctionCall::set_use_default_args); ClassDB::bind_method(D_METHOD("get_use_default_args"), &VisualScriptFunctionCall::get_use_default_args); ClassDB::bind_method(D_METHOD("_set_argument_cache", "argument_cache"), &VisualScriptFunctionCall::_set_argument_cache); ClassDB::bind_method(D_METHOD("_get_argument_cache"), &VisualScriptFunctionCall::_get_argument_cache); ClassDB::bind_method(D_METHOD("set_rpc_call_mode", "mode"), &VisualScriptFunctionCall::set_rpc_call_mode); ClassDB::bind_method(D_METHOD("get_rpc_call_mode"), &VisualScriptFunctionCall::get_rpc_call_mode); ClassDB::bind_method(D_METHOD("set_validate", "enable"), &VisualScriptFunctionCall::set_validate); ClassDB::bind_method(D_METHOD("get_validate"), &VisualScriptFunctionCall::get_validate); String bt; for (int i = 0; i < Variant::VARIANT_MAX; i++) { if (i > 0) { bt += ","; } bt += Variant::get_type_name(Variant::Type(i)); } List<String> script_extensions; for (int i = 0; i < ScriptServer::get_language_count(); i++) { ScriptServer::get_language(i)->get_recognized_extensions(&script_extensions); } String script_ext_hint; for (List<String>::Element *E = script_extensions.front(); E; E = E->next()) { if (script_ext_hint != String()) { script_ext_hint += ","; } script_ext_hint += "*." + E->get(); } ADD_PROPERTY(PropertyInfo(Variant::INT, "call_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance,Basic Type,Singleton"), "set_call_mode", "get_call_mode"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_script", PROPERTY_HINT_FILE, script_ext_hint), "set_base_script", "get_base_script"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "singleton"), "set_singleton", "get_singleton"); ADD_PROPERTY(PropertyInfo(Variant::INT, "basic_type", PROPERTY_HINT_ENUM, bt), "set_basic_type", "get_basic_type"); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path"); ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "argument_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_argument_cache", "_get_argument_cache"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "function"), "set_function", "get_function"); //when set, if loaded properly, will override argument count. ADD_PROPERTY(PropertyInfo(Variant::INT, "use_default_args"), "set_use_default_args", "get_use_default_args"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "validate"), "set_validate", "get_validate"); ADD_PROPERTY(PropertyInfo(Variant::INT, "rpc_call_mode", PROPERTY_HINT_ENUM, "Disabled,Reliable,Unreliable,ReliableToID,UnreliableToID"), "set_rpc_call_mode", "get_rpc_call_mode"); //when set, if loaded properly, will override argument count. BIND_ENUM_CONSTANT(CALL_MODE_SELF); BIND_ENUM_CONSTANT(CALL_MODE_NODE_PATH); BIND_ENUM_CONSTANT(CALL_MODE_INSTANCE); BIND_ENUM_CONSTANT(CALL_MODE_BASIC_TYPE); BIND_ENUM_CONSTANT(CALL_MODE_SINGLETON); BIND_ENUM_CONSTANT(RPC_DISABLED); BIND_ENUM_CONSTANT(RPC_RELIABLE); BIND_ENUM_CONSTANT(RPC_UNRELIABLE); BIND_ENUM_CONSTANT(RPC_RELIABLE_TO_ID); BIND_ENUM_CONSTANT(RPC_UNRELIABLE_TO_ID); } class VisualScriptNodeInstanceFunctionCall : public VisualScriptNodeInstance { public: VisualScriptFunctionCall::CallMode call_mode; NodePath node_path; int input_args; bool validate; int returns; VisualScriptFunctionCall::RPCCallMode rpc_mode; StringName function; StringName singleton; VisualScriptFunctionCall *node; VisualScriptInstance *instance; //virtual int get_working_memory_size() const { return 0; } //virtual bool is_output_port_unsequenced(int p_idx) const { return false; } //virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; } _FORCE_INLINE_ bool call_rpc(Object *p_base, const Variant **p_args, int p_argcount) { if (!p_base) { return false; } Node *node = Object::cast_to<Node>(p_base); if (!node) { return false; } int to_id = 0; bool reliable = true; if (rpc_mode >= VisualScriptFunctionCall::RPC_RELIABLE_TO_ID) { to_id = *p_args[0]; p_args += 1; p_argcount -= 1; if (rpc_mode == VisualScriptFunctionCall::RPC_UNRELIABLE_TO_ID) { reliable = false; } } else if (rpc_mode == VisualScriptFunctionCall::RPC_UNRELIABLE) { reliable = false; } node->rpcp(to_id, !reliable, function, p_args, p_argcount); return true; } virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) { switch (call_mode) { case VisualScriptFunctionCall::CALL_MODE_SELF: { Object *object = instance->get_owner_ptr(); if (rpc_mode) { call_rpc(object, p_inputs, input_args); } else if (returns) { *p_outputs[0] = object->call(function, p_inputs, input_args, r_error); } else { object->call(function, p_inputs, input_args, r_error); } } break; case VisualScriptFunctionCall::CALL_MODE_NODE_PATH: { Node *node = Object::cast_to<Node>(instance->get_owner_ptr()); if (!node) { r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = "Base object is not a Node!"; return 0; } Node *another = node->get_node(node_path); if (!another) { r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = "Path does not lead Node!"; return 0; } if (rpc_mode) { call_rpc(node, p_inputs, input_args); } else if (returns) { *p_outputs[0] = another->call(function, p_inputs, input_args, r_error); } else { another->call(function, p_inputs, input_args, r_error); } } break; case VisualScriptFunctionCall::CALL_MODE_INSTANCE: case VisualScriptFunctionCall::CALL_MODE_BASIC_TYPE: { Variant v = *p_inputs[0]; if (rpc_mode) { Object *obj = v; if (obj) { call_rpc(obj, p_inputs + 1, input_args - 1); } } else if (returns) { if (call_mode == VisualScriptFunctionCall::CALL_MODE_INSTANCE) { if (returns >= 2) { *p_outputs[1] = v.call(function, p_inputs + 1, input_args, r_error); } else if (returns == 1) { v.call(function, p_inputs + 1, input_args, r_error); } else { r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = "Invalid returns count for call_mode == CALL_MODE_INSTANCE"; return 0; } } else { *p_outputs[0] = v.call(function, p_inputs + 1, input_args, r_error); } } else { v.call(function, p_inputs + 1, input_args, r_error); } if (call_mode == VisualScriptFunctionCall::CALL_MODE_INSTANCE) { *p_outputs[0] = *p_inputs[0]; } } break; case VisualScriptFunctionCall::CALL_MODE_SINGLETON: { Object *object = Engine::get_singleton()->get_singleton_object(singleton); if (!object) { r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = "Invalid singleton name: '" + String(singleton) + "'"; return 0; } if (rpc_mode) { call_rpc(object, p_inputs, input_args); } else if (returns) { *p_outputs[0] = object->call(function, p_inputs, input_args, r_error); } else { object->call(function, p_inputs, input_args, r_error); } } break; } if (!validate) { //ignore call errors if validation is disabled r_error.error = Variant::CallError::CALL_OK; r_error_str = String(); } return 0; } }; VisualScriptNodeInstance *VisualScriptFunctionCall::instance(VisualScriptInstance *p_instance) { VisualScriptNodeInstanceFunctionCall *instance = memnew(VisualScriptNodeInstanceFunctionCall); instance->node = this; instance->instance = p_instance; instance->singleton = singleton; instance->function = function; instance->call_mode = call_mode; instance->returns = get_output_value_port_count(); instance->node_path = base_path; instance->input_args = get_input_value_port_count() - ((call_mode == CALL_MODE_BASIC_TYPE || call_mode == CALL_MODE_INSTANCE) ? 1 : 0); instance->rpc_mode = rpc_call_mode; instance->validate = validate; return instance; } VisualScriptFunctionCall::TypeGuess VisualScriptFunctionCall::guess_output_type(TypeGuess *p_inputs, int p_output) const { if (p_output == 0 && call_mode == CALL_MODE_INSTANCE) { return p_inputs[0]; } return VisualScriptNode::guess_output_type(p_inputs, p_output); } VisualScriptFunctionCall::VisualScriptFunctionCall() { validate = true; call_mode = CALL_MODE_SELF; basic_type = Variant::NIL; use_default_args = 0; base_type = "Object"; rpc_call_mode = RPC_DISABLED; } template <VisualScriptFunctionCall::CallMode cmode> static Ref<VisualScriptNode> create_function_call_node(const String &p_name) { Ref<VisualScriptFunctionCall> node; node.instance(); node->set_call_mode(cmode); return node; } ////////////////////////////////////////// ////////////////SET////////////////////// ////////////////////////////////////////// int VisualScriptPropertySet::get_output_sequence_port_count() const { return call_mode != CALL_MODE_BASIC_TYPE ? 1 : 0; //return 1; //Adding a sequence port to set_basic_type breaks backwards compatibility } bool VisualScriptPropertySet::has_input_sequence_port() const { return call_mode != CALL_MODE_BASIC_TYPE; //return 1; //Adding a sequence port to set_basic_type breaks backwards compatibility } Node *VisualScriptPropertySet::_get_base_node() const { #ifdef TOOLS_ENABLED Ref<Script> script = get_visual_script(); if (!script.is_valid()) { return nullptr; } MainLoop *main_loop = OS::get_singleton()->get_main_loop(); SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop); if (!scene_tree) { return nullptr; } Node *edited_scene = scene_tree->get_edited_scene_root(); if (!edited_scene) { return nullptr; } Node *script_node = _find_script_node(edited_scene, edited_scene, script); if (!script_node) { return nullptr; } if (!script_node->has_node(base_path)) { return nullptr; } Node *path_to = script_node->get_node(base_path); return path_to; #else return NULL; #endif } StringName VisualScriptPropertySet::_get_base_type() const { if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) { return get_visual_script()->get_instance_base_type(); } else if (call_mode == CALL_MODE_NODE_PATH && get_visual_script().is_valid()) { Node *path = _get_base_node(); if (path) { return path->get_class(); } } return base_type; } int VisualScriptPropertySet::get_input_value_port_count() const { int pc = (call_mode == CALL_MODE_BASIC_TYPE || call_mode == CALL_MODE_INSTANCE) ? 2 : 1; return pc; } int VisualScriptPropertySet::get_output_value_port_count() const { return (call_mode == CALL_MODE_BASIC_TYPE || call_mode == CALL_MODE_INSTANCE) ? 1 : 0; } String VisualScriptPropertySet::get_output_sequence_port_text(int p_port) const { return String(); } void VisualScriptPropertySet::_adjust_input_index(PropertyInfo &pinfo) const { if (index != StringName()) { Variant v; Variant::CallError ce; v = Variant::construct(pinfo.type, nullptr, 0, ce); Variant i = v.get(index); pinfo.type = i.get_type(); } } PropertyInfo VisualScriptPropertySet::get_input_value_port_info(int p_idx) const { if (call_mode == CALL_MODE_INSTANCE || call_mode == CALL_MODE_BASIC_TYPE) { if (p_idx == 0) { PropertyInfo pi; pi.type = (call_mode == CALL_MODE_INSTANCE ? Variant::OBJECT : basic_type); pi.name = (call_mode == CALL_MODE_INSTANCE ? String("instance") : Variant::get_type_name(basic_type).to_lower()); _adjust_input_index(pi); return pi; } } List<PropertyInfo> props; ClassDB::get_property_list(_get_base_type(), &props, false); for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { if (E->get().name == property) { String detail_prop_name = property; if (index != StringName()) { detail_prop_name += "." + String(index); } PropertyInfo pinfo = PropertyInfo(E->get().type, detail_prop_name, PROPERTY_HINT_TYPE_STRING, E->get().hint_string); _adjust_input_index(pinfo); return pinfo; } } PropertyInfo pinfo = type_cache; _adjust_input_index(pinfo); return pinfo; } PropertyInfo VisualScriptPropertySet::get_output_value_port_info(int p_idx) const { if (call_mode == CALL_MODE_BASIC_TYPE) { return PropertyInfo(basic_type, "pass"); } else if (call_mode == CALL_MODE_INSTANCE) { return PropertyInfo(Variant::OBJECT, "pass", PROPERTY_HINT_TYPE_STRING, get_base_type()); } else { return PropertyInfo(); } } String VisualScriptPropertySet::get_caption() const { static const char *opname[ASSIGN_OP_MAX] = { "Set", "Add", "Subtract", "Multiply", "Divide", "Mod", "ShiftLeft", "ShiftRight", "BitAnd", "BitOr", "BitXor" }; String prop = String(opname[assign_op]) + " " + property; if (index != StringName()) { prop += "." + String(index); } return prop; } String VisualScriptPropertySet::get_text() const { if (!has_input_sequence_port()) { return ""; } if (call_mode == CALL_MODE_BASIC_TYPE) { return String("On ") + Variant::get_type_name(basic_type); } else if (call_mode == CALL_MODE_INSTANCE) { return String("On ") + base_type; } else if (call_mode == CALL_MODE_NODE_PATH) { return " [" + String(base_path.simplified()) + "]"; } else { return "On Self"; } } void VisualScriptPropertySet::_update_base_type() { //cache it because this information may not be available on load if (call_mode == CALL_MODE_NODE_PATH) { Node *node = _get_base_node(); if (node) { base_type = node->get_class(); } } else if (call_mode == CALL_MODE_SELF) { if (get_visual_script().is_valid()) { base_type = get_visual_script()->get_instance_base_type(); } } } void VisualScriptPropertySet::set_basic_type(Variant::Type p_type) { if (basic_type == p_type) { return; } basic_type = p_type; _change_notify(); _update_base_type(); ports_changed_notify(); } Variant::Type VisualScriptPropertySet::get_basic_type() const { return basic_type; } void VisualScriptPropertySet::set_base_type(const StringName &p_type) { if (base_type == p_type) { return; } base_type = p_type; _change_notify(); ports_changed_notify(); } StringName VisualScriptPropertySet::get_base_type() const { return base_type; } void VisualScriptPropertySet::set_base_script(const String &p_path) { if (base_script == p_path) { return; } base_script = p_path; _change_notify(); ports_changed_notify(); } String VisualScriptPropertySet::get_base_script() const { return base_script; } void VisualScriptPropertySet::_update_cache() { if (!Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop())) { return; } if (!Engine::get_singleton()->is_editor_hint()) { //only update cache if editor exists, it's pointless otherwise return; } if (call_mode == CALL_MODE_BASIC_TYPE) { //not super efficient.. Variant v; Variant::CallError ce; v = Variant::construct(basic_type, nullptr, 0, ce); List<PropertyInfo> pinfo; v.get_property_list(&pinfo); for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { if (E->get().name == property) { type_cache = E->get(); } } } else { StringName type; Ref<Script> script; Node *node = nullptr; if (call_mode == CALL_MODE_NODE_PATH) { node = _get_base_node(); if (node) { type = node->get_class(); base_type = type; //cache, too script = node->get_script(); } } else if (call_mode == CALL_MODE_SELF) { if (get_visual_script().is_valid()) { type = get_visual_script()->get_instance_base_type(); base_type = type; //cache, too script = get_visual_script(); } } else if (call_mode == CALL_MODE_INSTANCE) { type = base_type; if (base_script != String()) { if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) { ScriptServer::edit_request_func(base_script); //make sure it's loaded } if (ResourceCache::has(base_script)) { script = Ref<Resource>(ResourceCache::get(base_script)); } else { return; } } } List<PropertyInfo> pinfo; if (node) { node->get_property_list(&pinfo); } else { ClassDB::get_property_list(type, &pinfo); } if (script.is_valid()) { script->get_script_property_list(&pinfo); } for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { if (E->get().name == property) { type_cache = E->get(); return; } } } } void VisualScriptPropertySet::set_property(const StringName &p_type) { if (property == p_type) { return; } property = p_type; index = StringName(); _update_cache(); _change_notify(); ports_changed_notify(); } StringName VisualScriptPropertySet::get_property() const { return property; } void VisualScriptPropertySet::set_base_path(const NodePath &p_type) { if (base_path == p_type) { return; } base_path = p_type; _update_base_type(); _change_notify(); ports_changed_notify(); } NodePath VisualScriptPropertySet::get_base_path() const { return base_path; } void VisualScriptPropertySet::set_call_mode(CallMode p_mode) { if (call_mode == p_mode) { return; } call_mode = p_mode; _update_base_type(); _change_notify(); ports_changed_notify(); } VisualScriptPropertySet::CallMode VisualScriptPropertySet::get_call_mode() const { return call_mode; } void VisualScriptPropertySet::_set_type_cache(const Dictionary &p_type) { type_cache = PropertyInfo::from_dict(p_type); } Dictionary VisualScriptPropertySet::_get_type_cache() const { return type_cache; } void VisualScriptPropertySet::set_index(const StringName &p_type) { if (index == p_type) { return; } index = p_type; _update_cache(); _change_notify(); ports_changed_notify(); } StringName VisualScriptPropertySet::get_index() const { return index; } void VisualScriptPropertySet::set_assign_op(AssignOp p_op) { ERR_FAIL_INDEX(p_op, ASSIGN_OP_MAX); if (assign_op == p_op) { return; } assign_op = p_op; _update_cache(); _change_notify(); ports_changed_notify(); } VisualScriptPropertySet::AssignOp VisualScriptPropertySet::get_assign_op() const { return assign_op; } void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const { if (property.name == "base_type") { if (call_mode != CALL_MODE_INSTANCE) { property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL; } } if (property.name == "base_script") { if (call_mode != CALL_MODE_INSTANCE) { property.usage = 0; } } if (property.name == "basic_type") { if (call_mode != CALL_MODE_BASIC_TYPE) { property.usage = 0; } } if (property.name == "node_path") { if (call_mode != CALL_MODE_NODE_PATH) { property.usage = 0; } else { Node *bnode = _get_base_node(); if (bnode) { property.hint_string = bnode->get_path(); //convert to loong string } } } if (property.name == "property") { if (call_mode == CALL_MODE_BASIC_TYPE) { property.hint = PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE; property.hint_string = Variant::get_type_name(basic_type); } else if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) { property.hint = PROPERTY_HINT_PROPERTY_OF_SCRIPT; property.hint_string = itos(get_visual_script()->get_instance_id()); } else if (call_mode == CALL_MODE_INSTANCE) { property.hint = PROPERTY_HINT_PROPERTY_OF_BASE_TYPE; property.hint_string = base_type; if (base_script != String()) { if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) { ScriptServer::edit_request_func(base_script); //make sure it's loaded } if (ResourceCache::has(base_script)) { Ref<Script> script = Ref<Resource>(ResourceCache::get(base_script)); if (script.is_valid()) { property.hint = PROPERTY_HINT_PROPERTY_OF_SCRIPT; property.hint_string = itos(script->get_instance_id()); } } } } else if (call_mode == CALL_MODE_NODE_PATH) { Node *node = _get_base_node(); if (node) { property.hint = PROPERTY_HINT_PROPERTY_OF_INSTANCE; property.hint_string = itos(node->get_instance_id()); } else { property.hint = PROPERTY_HINT_PROPERTY_OF_BASE_TYPE; property.hint_string = get_base_type(); } } } if (property.name == "index") { Variant::CallError ce; Variant v = Variant::construct(type_cache.type, nullptr, 0, ce); List<PropertyInfo> plist; v.get_property_list(&plist); String options = ""; for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { options += "," + E->get().name; } property.hint = PROPERTY_HINT_ENUM; property.hint_string = options; property.type = Variant::STRING; if (options == "") { property.usage = 0; //hide if type has no usable index } } } void VisualScriptPropertySet::_bind_methods() { ClassDB::bind_method(D_METHOD("set_base_type", "base_type"), &VisualScriptPropertySet::set_base_type); ClassDB::bind_method(D_METHOD("get_base_type"), &VisualScriptPropertySet::get_base_type); ClassDB::bind_method(D_METHOD("set_base_script", "base_script"), &VisualScriptPropertySet::set_base_script); ClassDB::bind_method(D_METHOD("get_base_script"), &VisualScriptPropertySet::get_base_script); ClassDB::bind_method(D_METHOD("set_basic_type", "basic_type"), &VisualScriptPropertySet::set_basic_type); ClassDB::bind_method(D_METHOD("get_basic_type"), &VisualScriptPropertySet::get_basic_type); ClassDB::bind_method(D_METHOD("_set_type_cache", "type_cache"), &VisualScriptPropertySet::_set_type_cache); ClassDB::bind_method(D_METHOD("_get_type_cache"), &VisualScriptPropertySet::_get_type_cache); ClassDB::bind_method(D_METHOD("set_property", "property"), &VisualScriptPropertySet::set_property); ClassDB::bind_method(D_METHOD("get_property"), &VisualScriptPropertySet::get_property); ClassDB::bind_method(D_METHOD("set_call_mode", "mode"), &VisualScriptPropertySet::set_call_mode); ClassDB::bind_method(D_METHOD("get_call_mode"), &VisualScriptPropertySet::get_call_mode); ClassDB::bind_method(D_METHOD("set_base_path", "base_path"), &VisualScriptPropertySet::set_base_path); ClassDB::bind_method(D_METHOD("get_base_path"), &VisualScriptPropertySet::get_base_path); ClassDB::bind_method(D_METHOD("set_index", "index"), &VisualScriptPropertySet::set_index); ClassDB::bind_method(D_METHOD("get_index"), &VisualScriptPropertySet::get_index); ClassDB::bind_method(D_METHOD("set_assign_op", "assign_op"), &VisualScriptPropertySet::set_assign_op); ClassDB::bind_method(D_METHOD("get_assign_op"), &VisualScriptPropertySet::get_assign_op); String bt; for (int i = 0; i < Variant::VARIANT_MAX; i++) { if (i > 0) { bt += ","; } bt += Variant::get_type_name(Variant::Type(i)); } List<String> script_extensions; for (int i = 0; i < ScriptServer::get_language_count(); i++) { ScriptServer::get_language(i)->get_recognized_extensions(&script_extensions); } String script_ext_hint; for (List<String>::Element *E = script_extensions.front(); E; E = E->next()) { if (script_ext_hint != String()) { script_ext_hint += ","; } script_ext_hint += "*." + E->get(); } ADD_PROPERTY(PropertyInfo(Variant::INT, "set_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance,Basic Type"), "set_call_mode", "get_call_mode"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_script", PROPERTY_HINT_FILE, script_ext_hint), "set_base_script", "get_base_script"); ADD_PROPERTY(PropertyInfo(Variant::INT, "type_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_type_cache", "_get_type_cache"); ADD_PROPERTY(PropertyInfo(Variant::INT, "basic_type", PROPERTY_HINT_ENUM, bt), "set_basic_type", "get_basic_type"); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "property"), "set_property", "get_property"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "index"), "set_index", "get_index"); ADD_PROPERTY(PropertyInfo(Variant::INT, "assign_op", PROPERTY_HINT_ENUM, "Assign,Add,Sub,Mul,Div,Mod,ShiftLeft,ShiftRight,BitAnd,BitOr,Bitxor"), "set_assign_op", "get_assign_op"); BIND_ENUM_CONSTANT(CALL_MODE_SELF); BIND_ENUM_CONSTANT(CALL_MODE_NODE_PATH); BIND_ENUM_CONSTANT(CALL_MODE_INSTANCE); BIND_ENUM_CONSTANT(CALL_MODE_BASIC_TYPE); BIND_ENUM_CONSTANT(ASSIGN_OP_NONE); BIND_ENUM_CONSTANT(ASSIGN_OP_ADD); BIND_ENUM_CONSTANT(ASSIGN_OP_SUB); BIND_ENUM_CONSTANT(ASSIGN_OP_MUL); BIND_ENUM_CONSTANT(ASSIGN_OP_DIV); BIND_ENUM_CONSTANT(ASSIGN_OP_MOD); BIND_ENUM_CONSTANT(ASSIGN_OP_SHIFT_LEFT); BIND_ENUM_CONSTANT(ASSIGN_OP_SHIFT_RIGHT); BIND_ENUM_CONSTANT(ASSIGN_OP_BIT_AND); BIND_ENUM_CONSTANT(ASSIGN_OP_BIT_OR); BIND_ENUM_CONSTANT(ASSIGN_OP_BIT_XOR); } class VisualScriptNodeInstancePropertySet : public VisualScriptNodeInstance { public: VisualScriptPropertySet::CallMode call_mode; NodePath node_path; StringName property; VisualScriptPropertySet *node; VisualScriptInstance *instance; VisualScriptPropertySet::AssignOp assign_op; StringName index; bool needs_get; //virtual int get_working_memory_size() const { return 0; } //virtual bool is_output_port_unsequenced(int p_idx) const { return false; } //virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; } _FORCE_INLINE_ void _process_get(Variant &source, const Variant &p_argument, bool &valid) { if (index != StringName() && assign_op == VisualScriptPropertySet::ASSIGN_OP_NONE) { source.set_named(index, p_argument, &valid); } else { Variant value; if (index != StringName()) { value = source.get_named(index, &valid); } else { value = source; } switch (assign_op) { case VisualScriptPropertySet::ASSIGN_OP_NONE: { //should never get here } break; case VisualScriptPropertySet::ASSIGN_OP_ADD: { value = Variant::evaluate(Variant::OP_ADD, value, p_argument); } break; case VisualScriptPropertySet::ASSIGN_OP_SUB: { value = Variant::evaluate(Variant::OP_SUBTRACT, value, p_argument); } break; case VisualScriptPropertySet::ASSIGN_OP_MUL: { value = Variant::evaluate(Variant::OP_MULTIPLY, value, p_argument); } break; case VisualScriptPropertySet::ASSIGN_OP_DIV: { value = Variant::evaluate(Variant::OP_DIVIDE, value, p_argument); } break; case VisualScriptPropertySet::ASSIGN_OP_MOD: { value = Variant::evaluate(Variant::OP_MODULE, value, p_argument); } break; case VisualScriptPropertySet::ASSIGN_OP_SHIFT_LEFT: { value = Variant::evaluate(Variant::OP_SHIFT_LEFT, value, p_argument); } break; case VisualScriptPropertySet::ASSIGN_OP_SHIFT_RIGHT: { value = Variant::evaluate(Variant::OP_SHIFT_RIGHT, value, p_argument); } break; case VisualScriptPropertySet::ASSIGN_OP_BIT_AND: { value = Variant::evaluate(Variant::OP_BIT_AND, value, p_argument); } break; case VisualScriptPropertySet::ASSIGN_OP_BIT_OR: { value = Variant::evaluate(Variant::OP_BIT_OR, value, p_argument); } break; case VisualScriptPropertySet::ASSIGN_OP_BIT_XOR: { value = Variant::evaluate(Variant::OP_BIT_XOR, value, p_argument); } break; default: { } } if (index != StringName()) { source.set_named(index, value, &valid); } else { source = value; } } } virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) { switch (call_mode) { case VisualScriptPropertySet::CALL_MODE_SELF: { Object *object = instance->get_owner_ptr(); bool valid; if (needs_get) { Variant value = object->get(property, &valid); _process_get(value, *p_inputs[0], valid); object->set(property, value, &valid); } else { object->set(property, *p_inputs[0], &valid); } if (!valid) { r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = "Invalid set value '" + String(*p_inputs[0]) + "' on property '" + String(property) + "' of type " + object->get_class(); } } break; case VisualScriptPropertySet::CALL_MODE_NODE_PATH: { Node *node = Object::cast_to<Node>(instance->get_owner_ptr()); if (!node) { r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = "Base object is not a Node!"; return 0; } Node *another = node->get_node(node_path); if (!another) { r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = "Path does not lead Node!"; return 0; } bool valid; if (needs_get) { Variant value = another->get(property, &valid); _process_get(value, *p_inputs[0], valid); another->set(property, value, &valid); } else { another->set(property, *p_inputs[0], &valid); } if (!valid) { r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = "Invalid set value '" + String(*p_inputs[0]) + "' on property '" + String(property) + "' of type " + another->get_class(); } } break; case VisualScriptPropertySet::CALL_MODE_INSTANCE: case VisualScriptPropertySet::CALL_MODE_BASIC_TYPE: { Variant v = *p_inputs[0]; bool valid; if (needs_get) { Variant value = v.get_named(property, &valid); _process_get(value, *p_inputs[1], valid); v.set_named(property, value, &valid); } else { v.set_named(property, *p_inputs[1], &valid); } if (!valid) { r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = "Invalid set value '" + String(*p_inputs[1]) + "' (" + Variant::get_type_name(p_inputs[1]->get_type()) + ") on property '" + String(property) + "' of type " + Variant::get_type_name(v.get_type()); } *p_outputs[0] = v; } break; } return 0; } }; VisualScriptNodeInstance *VisualScriptPropertySet::instance(VisualScriptInstance *p_instance) { VisualScriptNodeInstancePropertySet *instance = memnew(VisualScriptNodeInstancePropertySet); instance->node = this; instance->instance = p_instance; instance->property = property; instance->call_mode = call_mode; instance->node_path = base_path; instance->assign_op = assign_op; instance->index = index; instance->needs_get = index != StringName() || assign_op != ASSIGN_OP_NONE; return instance; } VisualScriptPropertySet::TypeGuess VisualScriptPropertySet::guess_output_type(TypeGuess *p_inputs, int p_output) const { if (p_output == 0 && call_mode == CALL_MODE_INSTANCE) { return p_inputs[0]; } return VisualScriptNode::guess_output_type(p_inputs, p_output); } VisualScriptPropertySet::VisualScriptPropertySet() { assign_op = ASSIGN_OP_NONE; call_mode = CALL_MODE_SELF; base_type = "Object"; basic_type = Variant::NIL; } template <VisualScriptPropertySet::CallMode cmode> static Ref<VisualScriptNode> create_property_set_node(const String &p_name) { Ref<VisualScriptPropertySet> node; node.instance(); node->set_call_mode(cmode); return node; } ////////////////////////////////////////// ////////////////GET////////////////////// ////////////////////////////////////////// int VisualScriptPropertyGet::get_output_sequence_port_count() const { return 0; // (call_mode==CALL_MODE_SELF || call_mode==CALL_MODE_NODE_PATH)?0:1; } bool VisualScriptPropertyGet::has_input_sequence_port() const { return false; //(call_mode==CALL_MODE_SELF || call_mode==CALL_MODE_NODE_PATH)?false:true; } void VisualScriptPropertyGet::_update_base_type() { //cache it because this information may not be available on load if (call_mode == CALL_MODE_NODE_PATH) { Node *node = _get_base_node(); if (node) { base_type = node->get_class(); } } else if (call_mode == CALL_MODE_SELF) { if (get_visual_script().is_valid()) { base_type = get_visual_script()->get_instance_base_type(); } } } Node *VisualScriptPropertyGet::_get_base_node() const { #ifdef TOOLS_ENABLED Ref<Script> script = get_visual_script(); if (!script.is_valid()) { return nullptr; } MainLoop *main_loop = OS::get_singleton()->get_main_loop(); SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop); if (!scene_tree) { return nullptr; } Node *edited_scene = scene_tree->get_edited_scene_root(); if (!edited_scene) { return nullptr; } Node *script_node = _find_script_node(edited_scene, edited_scene, script); if (!script_node) { return nullptr; } if (!script_node->has_node(base_path)) { return nullptr; } Node *path_to = script_node->get_node(base_path); return path_to; #else return NULL; #endif } StringName VisualScriptPropertyGet::_get_base_type() const { if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) { return get_visual_script()->get_instance_base_type(); } else if (call_mode == CALL_MODE_NODE_PATH && get_visual_script().is_valid()) { Node *path = _get_base_node(); if (path) { return path->get_class(); } } return base_type; } int VisualScriptPropertyGet::get_input_value_port_count() const { return (call_mode == CALL_MODE_BASIC_TYPE || call_mode == CALL_MODE_INSTANCE) ? 1 : 0; } int VisualScriptPropertyGet::get_output_value_port_count() const { // port 'pass' not backported to 3.x to keep script backwards compatibility return 1; } String VisualScriptPropertyGet::get_output_sequence_port_text(int p_port) const { return String(); } PropertyInfo VisualScriptPropertyGet::get_input_value_port_info(int p_idx) const { if (call_mode == CALL_MODE_INSTANCE || call_mode == CALL_MODE_BASIC_TYPE) { if (p_idx == 0) { PropertyInfo pi; pi.type = (call_mode == CALL_MODE_INSTANCE ? Variant::OBJECT : basic_type); pi.name = (call_mode == CALL_MODE_INSTANCE ? String("instance") : Variant::get_type_name(basic_type).to_lower()); return pi; } } return PropertyInfo(); } PropertyInfo VisualScriptPropertyGet::get_output_value_port_info(int p_idx) const { // port 'pass' not backported to 3.x to keep script backwards compatibility List<PropertyInfo> props; ClassDB::get_property_list(_get_base_type(), &props, false); for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { if (E->get().name == property) { PropertyInfo pinfo = PropertyInfo(E->get().type, String(property) + "." + String(index), E->get().hint, E->get().hint_string); _adjust_input_index(pinfo); return pinfo; } } PropertyInfo pinfo = PropertyInfo(type_cache, "value"); _adjust_input_index(pinfo); return pinfo; } String VisualScriptPropertyGet::get_caption() const { String prop = String("Get ") + property; if (index != StringName()) { prop += "." + String(index); } return prop; } String VisualScriptPropertyGet::get_text() const { if (call_mode == CALL_MODE_BASIC_TYPE) { return String("On ") + Variant::get_type_name(basic_type); } else if (call_mode == CALL_MODE_INSTANCE) { return String("On ") + base_type; } else if (call_mode == CALL_MODE_NODE_PATH) { return " [" + String(base_path.simplified()) + "]"; } else { return "On Self"; } } void VisualScriptPropertyGet::set_base_type(const StringName &p_type) { if (base_type == p_type) { return; } base_type = p_type; _change_notify(); ports_changed_notify(); } StringName VisualScriptPropertyGet::get_base_type() const { return base_type; } void VisualScriptPropertyGet::set_base_script(const String &p_path) { if (base_script == p_path) { return; } base_script = p_path; _change_notify(); ports_changed_notify(); } String VisualScriptPropertyGet::get_base_script() const { return base_script; } void VisualScriptPropertyGet::_update_cache() { if (call_mode == CALL_MODE_BASIC_TYPE) { //not super efficient.. Variant v; Variant::CallError ce; v = Variant::construct(basic_type, nullptr, 0, ce); List<PropertyInfo> pinfo; v.get_property_list(&pinfo); for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { if (E->get().name == property) { type_cache = E->get().type; return; } } } else { StringName type; Ref<Script> script; Node *node = nullptr; if (call_mode == CALL_MODE_NODE_PATH) { node = _get_base_node(); if (node) { type = node->get_class(); base_type = type; //cache, too script = node->get_script(); } } else if (call_mode == CALL_MODE_SELF) { if (get_visual_script().is_valid()) { type = get_visual_script()->get_instance_base_type(); base_type = type; //cache, too script = get_visual_script(); } } else if (call_mode == CALL_MODE_INSTANCE) { type = base_type; if (base_script != String()) { if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) { ScriptServer::edit_request_func(base_script); //make sure it's loaded } if (ResourceCache::has(base_script)) { script = Ref<Resource>(ResourceCache::get(base_script)); } else { return; } } } bool valid = false; Variant::Type type_ret; type_ret = ClassDB::get_property_type(base_type, property, &valid); if (valid) { type_cache = type_ret; return; //all dandy } if (node) { Variant prop = node->get(property, &valid); if (valid) { type_cache = prop.get_type(); return; //all dandy again } } if (script.is_valid()) { type_ret = script->get_static_property_type(property, &valid); if (valid) { type_cache = type_ret; return; //all dandy } } } } void VisualScriptPropertyGet::set_property(const StringName &p_type) { if (property == p_type) { return; } property = p_type; _update_cache(); _change_notify(); ports_changed_notify(); } StringName VisualScriptPropertyGet::get_property() const { return property; } void VisualScriptPropertyGet::set_base_path(const NodePath &p_type) { if (base_path == p_type) { return; } base_path = p_type; _change_notify(); _update_base_type(); ports_changed_notify(); } NodePath VisualScriptPropertyGet::get_base_path() const { return base_path; } void VisualScriptPropertyGet::set_call_mode(CallMode p_mode) { if (call_mode == p_mode) { return; } call_mode = p_mode; _change_notify(); _update_base_type(); ports_changed_notify(); } VisualScriptPropertyGet::CallMode VisualScriptPropertyGet::get_call_mode() const { return call_mode; } void VisualScriptPropertyGet::set_basic_type(Variant::Type p_type) { if (basic_type == p_type) { return; } basic_type = p_type; _change_notify(); ports_changed_notify(); } Variant::Type VisualScriptPropertyGet::get_basic_type() const { return basic_type; } void VisualScriptPropertyGet::_set_type_cache(Variant::Type p_type) { type_cache = p_type; } Variant::Type VisualScriptPropertyGet::_get_type_cache() const { return type_cache; } void VisualScriptPropertyGet::_adjust_input_index(PropertyInfo &pinfo) const { if (index != StringName()) { Variant v; Variant::CallError ce; v = Variant::construct(pinfo.type, nullptr, 0, ce); Variant i = v.get(index); pinfo.type = i.get_type(); } else { pinfo.name = String(property); } } void VisualScriptPropertyGet::set_index(const StringName &p_type) { if (index == p_type) { return; } index = p_type; _update_cache(); _change_notify(); ports_changed_notify(); } StringName VisualScriptPropertyGet::get_index() const { return index; } void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const { if (property.name == "base_type") { if (call_mode != CALL_MODE_INSTANCE) { property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL; } } if (property.name == "base_script") { if (call_mode != CALL_MODE_INSTANCE) { property.usage = 0; } } if (property.name == "basic_type") { if (call_mode != CALL_MODE_BASIC_TYPE) { property.usage = 0; } } if (property.name == "node_path") { if (call_mode != CALL_MODE_NODE_PATH) { property.usage = 0; } else { Node *bnode = _get_base_node(); if (bnode) { property.hint_string = bnode->get_path(); //convert to loong string } } } if (property.name == "property") { if (call_mode == CALL_MODE_BASIC_TYPE) { property.hint = PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE; property.hint_string = Variant::get_type_name(basic_type); } else if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) { property.hint = PROPERTY_HINT_PROPERTY_OF_SCRIPT; property.hint_string = itos(get_visual_script()->get_instance_id()); } else if (call_mode == CALL_MODE_INSTANCE) { property.hint = PROPERTY_HINT_PROPERTY_OF_BASE_TYPE; property.hint_string = base_type; if (base_script != String()) { if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) { ScriptServer::edit_request_func(base_script); //make sure it's loaded } if (ResourceCache::has(base_script)) { Ref<Script> script = Ref<Resource>(ResourceCache::get(base_script)); if (script.is_valid()) { property.hint = PROPERTY_HINT_PROPERTY_OF_SCRIPT; property.hint_string = itos(script->get_instance_id()); } } } } else if (call_mode == CALL_MODE_NODE_PATH) { Node *node = _get_base_node(); if (node) { property.hint = PROPERTY_HINT_PROPERTY_OF_INSTANCE; property.hint_string = itos(node->get_instance_id()); } else { property.hint = PROPERTY_HINT_PROPERTY_OF_BASE_TYPE; property.hint_string = get_base_type(); } } } if (property.name == "index") { Variant::CallError ce; Variant v = Variant::construct(type_cache, nullptr, 0, ce); List<PropertyInfo> plist; v.get_property_list(&plist); String options = ""; for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { options += "," + E->get().name; } property.hint = PROPERTY_HINT_ENUM; property.hint_string = options; property.type = Variant::STRING; if (options == "") { property.usage = 0; //hide if type has no usable index } } } void VisualScriptPropertyGet::_bind_methods() { ClassDB::bind_method(D_METHOD("set_base_type", "base_type"), &VisualScriptPropertyGet::set_base_type); ClassDB::bind_method(D_METHOD("get_base_type"), &VisualScriptPropertyGet::get_base_type); ClassDB::bind_method(D_METHOD("set_base_script", "base_script"), &VisualScriptPropertyGet::set_base_script); ClassDB::bind_method(D_METHOD("get_base_script"), &VisualScriptPropertyGet::get_base_script); ClassDB::bind_method(D_METHOD("set_basic_type", "basic_type"), &VisualScriptPropertyGet::set_basic_type); ClassDB::bind_method(D_METHOD("get_basic_type"), &VisualScriptPropertyGet::get_basic_type); ClassDB::bind_method(D_METHOD("_set_type_cache", "type_cache"), &VisualScriptPropertyGet::_set_type_cache); ClassDB::bind_method(D_METHOD("_get_type_cache"), &VisualScriptPropertyGet::_get_type_cache); ClassDB::bind_method(D_METHOD("set_property", "property"), &VisualScriptPropertyGet::set_property); ClassDB::bind_method(D_METHOD("get_property"), &VisualScriptPropertyGet::get_property); ClassDB::bind_method(D_METHOD("set_call_mode", "mode"), &VisualScriptPropertyGet::set_call_mode); ClassDB::bind_method(D_METHOD("get_call_mode"), &VisualScriptPropertyGet::get_call_mode); ClassDB::bind_method(D_METHOD("set_base_path", "base_path"), &VisualScriptPropertyGet::set_base_path); ClassDB::bind_method(D_METHOD("get_base_path"), &VisualScriptPropertyGet::get_base_path); ClassDB::bind_method(D_METHOD("set_index", "index"), &VisualScriptPropertyGet::set_index); ClassDB::bind_method(D_METHOD("get_index"), &VisualScriptPropertyGet::get_index); String bt; for (int i = 0; i < Variant::VARIANT_MAX; i++) { if (i > 0) { bt += ","; } bt += Variant::get_type_name(Variant::Type(i)); } List<String> script_extensions; for (int i = 0; i < ScriptServer::get_language_count(); i++) { ScriptServer::get_language(i)->get_recognized_extensions(&script_extensions); } String script_ext_hint; for (List<String>::Element *E = script_extensions.front(); E; E = E->next()) { if (script_ext_hint != String()) { script_ext_hint += ","; } script_ext_hint += "." + E->get(); } ADD_PROPERTY(PropertyInfo(Variant::INT, "set_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance,Basic Type"), "set_call_mode", "get_call_mode"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_script", PROPERTY_HINT_FILE, script_ext_hint), "set_base_script", "get_base_script"); ADD_PROPERTY(PropertyInfo(Variant::INT, "type_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_type_cache", "_get_type_cache"); ADD_PROPERTY(PropertyInfo(Variant::INT, "basic_type", PROPERTY_HINT_ENUM, bt), "set_basic_type", "get_basic_type"); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "property"), "set_property", "get_property"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "index", PROPERTY_HINT_ENUM), "set_index", "get_index"); BIND_ENUM_CONSTANT(CALL_MODE_SELF); BIND_ENUM_CONSTANT(CALL_MODE_NODE_PATH); BIND_ENUM_CONSTANT(CALL_MODE_INSTANCE); BIND_ENUM_CONSTANT(CALL_MODE_BASIC_TYPE); } class VisualScriptNodeInstancePropertyGet : public VisualScriptNodeInstance { public: VisualScriptPropertyGet::CallMode call_mode; NodePath node_path; StringName property; StringName index; VisualScriptPropertyGet *node; VisualScriptInstance *instance; virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) { switch (call_mode) { case VisualScriptPropertyGet::CALL_MODE_SELF: { Object *object = instance->get_owner_ptr(); bool valid; *p_outputs[0] = object->get(property, &valid); if (index != StringName()) { *p_outputs[0] = p_outputs[0]->get_named(index); } if (!valid) { r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = RTR("Invalid index property name."); return 0; } } break; case VisualScriptPropertyGet::CALL_MODE_NODE_PATH: { Node *node = Object::cast_to<Node>(instance->get_owner_ptr()); if (!node) { r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = RTR("Base object is not a Node!"); return 0; } Node *another = node->get_node(node_path); if (!another) { r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = RTR("Path does not lead Node!"); return 0; } bool valid; *p_outputs[0] = another->get(property, &valid); if (index != StringName()) { *p_outputs[0] = p_outputs[0]->get_named(index); } if (!valid) { r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = vformat(RTR("Invalid index property name '%s' in node %s."), String(property), another->get_name()); return 0; } } break; default: { bool valid; Variant v = *p_inputs[0]; // port 'pass' not backported to 3.x to keep script backwards compatibility *p_outputs[0] = v.get(property, &valid); if (index != StringName()) { *p_outputs[0] = p_outputs[0]->get_named(index); } if (!valid) { r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = RTR("Invalid index property name."); } }; } return 0; } }; VisualScriptNodeInstance *VisualScriptPropertyGet::instance(VisualScriptInstance *p_instance) { VisualScriptNodeInstancePropertyGet *instance = memnew(VisualScriptNodeInstancePropertyGet); instance->node = this; instance->instance = p_instance; instance->property = property; instance->call_mode = call_mode; instance->node_path = base_path; instance->index = index; return instance; } VisualScriptPropertyGet::VisualScriptPropertyGet() { call_mode = CALL_MODE_SELF; base_type = "Object"; basic_type = Variant::NIL; type_cache = Variant::NIL; } template <VisualScriptPropertyGet::CallMode cmode> static Ref<VisualScriptNode> create_property_get_node(const String &p_name) { Ref<VisualScriptPropertyGet> node; node.instance(); node->set_call_mode(cmode); return node; } ////////////////////////////////////////// ////////////////EMIT////////////////////// ////////////////////////////////////////// int VisualScriptEmitSignal::get_output_sequence_port_count() const { return 1; } bool VisualScriptEmitSignal::has_input_sequence_port() const { return true; } int VisualScriptEmitSignal::get_input_value_port_count() const { Ref<VisualScript> vs = get_visual_script(); if (vs.is_valid()) { if (!vs->has_custom_signal(name)) { return 0; } return vs->custom_signal_get_argument_count(name); } return 0; } int VisualScriptEmitSignal::get_output_value_port_count() const { return 0; } String VisualScriptEmitSignal::get_output_sequence_port_text(int p_port) const { return String(); } PropertyInfo VisualScriptEmitSignal::get_input_value_port_info(int p_idx) const { Ref<VisualScript> vs = get_visual_script(); if (vs.is_valid()) { if (!vs->has_custom_signal(name)) { return PropertyInfo(); } return PropertyInfo(vs->custom_signal_get_argument_type(name, p_idx), vs->custom_signal_get_argument_name(name, p_idx)); } return PropertyInfo(); } PropertyInfo VisualScriptEmitSignal::get_output_value_port_info(int p_idx) const { return PropertyInfo(); } String VisualScriptEmitSignal::get_caption() const { return "Emit " + String(name); } void VisualScriptEmitSignal::set_signal(const StringName &p_type) { if (name == p_type) { return; } name = p_type; _change_notify(); ports_changed_notify(); } StringName VisualScriptEmitSignal::get_signal() const { return name; } void VisualScriptEmitSignal::_validate_property(PropertyInfo &property) const { if (property.name == "signal") { property.hint = PROPERTY_HINT_ENUM; List<StringName> sigs; Ref<VisualScript> vs = get_visual_script(); if (vs.is_valid()) { vs->get_custom_signal_list(&sigs); } String ml; for (List<StringName>::Element *E = sigs.front(); E; E = E->next()) { if (ml != String()) { ml += ","; } ml += E->get(); } property.hint_string = ml; } } void VisualScriptEmitSignal::_bind_methods() { ClassDB::bind_method(D_METHOD("set_signal", "name"), &VisualScriptEmitSignal::set_signal); ClassDB::bind_method(D_METHOD("get_signal"), &VisualScriptEmitSignal::get_signal); ADD_PROPERTY(PropertyInfo(Variant::STRING, "signal"), "set_signal", "get_signal"); } class VisualScriptNodeInstanceEmitSignal : public VisualScriptNodeInstance { public: VisualScriptEmitSignal *node; VisualScriptInstance *instance; int argcount; StringName name; //virtual int get_working_memory_size() const { return 0; } //virtual bool is_output_port_unsequenced(int p_idx) const { return false; } //virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; } virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) { Object *obj = instance->get_owner_ptr(); obj->emit_signal(name, p_inputs, argcount); return 0; } }; VisualScriptNodeInstance *VisualScriptEmitSignal::instance(VisualScriptInstance *p_instance) { VisualScriptNodeInstanceEmitSignal *instance = memnew(VisualScriptNodeInstanceEmitSignal); instance->node = this; instance->instance = p_instance; instance->name = name; instance->argcount = get_input_value_port_count(); return instance; } VisualScriptEmitSignal::VisualScriptEmitSignal() { } static Ref<VisualScriptNode> create_basic_type_call_node(const String &p_name) { Vector<String> path = p_name.split("/"); ERR_FAIL_COND_V(path.size() < 4, Ref<VisualScriptNode>()); String base_type = path[2]; String method = path[3]; Ref<VisualScriptFunctionCall> node; node.instance(); Variant::Type type = Variant::VARIANT_MAX; for (int i = 0; i < Variant::VARIANT_MAX; i++) { if (Variant::get_type_name(Variant::Type(i)) == base_type) { type = Variant::Type(i); break; } } ERR_FAIL_COND_V(type == Variant::VARIANT_MAX, Ref<VisualScriptNode>()); node->set_call_mode(VisualScriptFunctionCall::CALL_MODE_BASIC_TYPE); node->set_basic_type(type); node->set_function(method); return node; } void register_visual_script_func_nodes() { VisualScriptLanguage::singleton->add_register_func("functions/call", create_node_generic<VisualScriptFunctionCall>); VisualScriptLanguage::singleton->add_register_func("functions/set", create_node_generic<VisualScriptPropertySet>); VisualScriptLanguage::singleton->add_register_func("functions/get", create_node_generic<VisualScriptPropertyGet>); //VisualScriptLanguage::singleton->add_register_func("functions/call_script/call_self",create_script_call_node<VisualScriptScriptCall::CALL_MODE_SELF>); //VisualScriptLanguage::singleton->add_register_func("functions/call_script/call_node",create_script_call_node<VisualScriptScriptCall::CALL_MODE_NODE_PATH>); VisualScriptLanguage::singleton->add_register_func("functions/emit_signal", create_node_generic<VisualScriptEmitSignal>); for (int i = 0; i < Variant::VARIANT_MAX; i++) { Variant::Type t = Variant::Type(i); String type_name = Variant::get_type_name(t); Variant::CallError ce; Variant vt = Variant::construct(t, nullptr, 0, ce); List<MethodInfo> ml; vt.get_method_list(&ml); for (List<MethodInfo>::Element *E = ml.front(); E; E = E->next()) { VisualScriptLanguage::singleton->add_register_func("functions/by_type/" + type_name + "/" + E->get().name, create_basic_type_call_node); } } }
* Sprite leer * * Mode 4 * +|-------------------+ * - - * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * +|-------------------+ * section sprite xdef mes_leer mes_leer dc.w $0100,$0000 dc.w 20,16,0,0 dc.l mcs_leer-* dc.l mms_leer-* dc.l 0 mcs_leer dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 mms_leer dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 dc.w $0000,$0000 * end
############################################################################### # Copyright 2018 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material ("Material") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # "License"), the following terms apply: # # 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. ############################################################################### .section .note.GNU-stack,"",%progbits .text .p2align 6, 0x90 .globl Decrypt_RIJ128_AES_NI .type Decrypt_RIJ128_AES_NI, @function Decrypt_RIJ128_AES_NI: lea (,%rdx,4), %rax lea (,%rax,4), %rax movdqu (%rdi), %xmm0 pxor (%rcx,%rax), %xmm0 cmp $(12), %rdx jl .Lkey_128gas_1 jz .Lkey_192gas_1 .Lkey_256gas_1: aesdec (208)(%rcx), %xmm0 aesdec (192)(%rcx), %xmm0 .Lkey_192gas_1: aesdec (176)(%rcx), %xmm0 aesdec (160)(%rcx), %xmm0 .Lkey_128gas_1: aesdec (144)(%rcx), %xmm0 aesdec (128)(%rcx), %xmm0 aesdec (112)(%rcx), %xmm0 aesdec (96)(%rcx), %xmm0 aesdec (80)(%rcx), %xmm0 aesdec (64)(%rcx), %xmm0 aesdec (48)(%rcx), %xmm0 aesdec (32)(%rcx), %xmm0 aesdec (16)(%rcx), %xmm0 aesdeclast (%rcx), %xmm0 movdqu %xmm0, (%rsi) vzeroupper ret .Lfe1: .size Decrypt_RIJ128_AES_NI, .Lfe1-(Decrypt_RIJ128_AES_NI)
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) Berkeley Softworks 1990 -- All Rights Reserved PROJECT: PC GEOS MODULE: DaisyWheel drivers FILE: fontDaisyWheelInfo.asm AUTHOR: Dave Durran REVISION HISTORY: Name Date Description ---- ---- ----------- Dave 8/28/92 Initial revision DESCRIPTION: This file contains the font information for the DaisyWheel printers Other Printers Supported by this resource: $Id: fontDaisyWheelInfo.asm,v 1.1 97/04/18 11:49:57 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ printerFontInfo segment resource word 0 ;dummy word to give non-zero offsets. ; mode info blocks d630nlq label word nptr d630_ROMAN12_10CPI nptr d630_ROMAN12_12CPI nptr d630_ROMAN12_15CPI nptr d630_ROMAN12_17CPI nptr d630_ROMAN12_PROP word 0 ; table terminator ; font info blocks d630_ROMAN12_10CPI FontEntry < FID_DTC_URW_ROMAN, ; 10 pitch draft font 12, ; 12 point font TP_10_PITCH, ; 10 pitch font PSS_ASCII7, ; PrinterCharSet offset pr_codes_Set10PitchRoman, ; control code ; text style ; legal bits mask PTS_BOLD or \ mask PTS_ITALIC or \ mask PTS_UNDERLINE, 0 ;Mandatory style bits > d630_ROMAN12_12CPI FontEntry < FID_DTC_URW_ROMAN, ; 12 pitch draft font 12, ; 12 point font TP_12_PITCH, ; 12 pitch font PSS_ASCII7, ; PrinterCharSet offset pr_codes_Set12PitchRoman, ; control code ; text style ; compatibility bits mask PTS_BOLD or \ mask PTS_ITALIC or \ mask PTS_UNDERLINE, 0 ;mandatory style bits > d630_ROMAN12_15CPI FontEntry < FID_DTC_URW_ROMAN, ; 15 pitch draft font 12, ; 12 point font TP_15_PITCH, ; 15 pitch font PSS_ASCII7, ; PrinterCharSet offset pr_codes_Set15PitchRoman, ; control code ; text style ; compatibility bits mask PTS_BOLD or \ mask PTS_ITALIC or \ mask PTS_UNDERLINE, 0 ;mandatory style bits > d630_ROMAN12_17CPI FontEntry < FID_DTC_URW_ROMAN, ; 17 pitch draft font 12, ; 12 point font TP_17_PITCH, ; 17 pitch font PSS_ASCII7, ; PrinterCharSet offset pr_codes_Set17PitchRoman, ; control code ; text style ; compatibility bits mask PTS_BOLD or \ mask PTS_ITALIC or \ mask PTS_UNDERLINE, 0 ;mandatory style bits > d630_ROMAN12_PROP FontEntry < FID_DTC_URW_ROMAN, ; proportional font 12, ; 12 point font TP_PROPORTIONAL, ; proportional font PSS_ASCII7, ; PrinterCharSet offset pr_codes_SetProportionalRoman, ; control code ; text style ; compatibility bits mask PTS_BOLD or \ mask PTS_ITALIC or \ mask PTS_UNDERLINE, 0 ;mandatory style bits > printerFontInfo ends
/* * ISPlanar.cpp * * Created on: Oct 10, 2016 * Author: hornak */ #include "ISCaptShrinkage.h" IS_Capt_Shrinkage::IS_Capt_Shrinkage() { // TODO Auto-generated constructor stub this->center_of_IS_front = Vector3d( 0.0 , 0.0 , 0.0 ); this->center_of_IS_rear = Vector3d( -1.0 , 0.0 , 0.0 ); this->radius_of_IS = 1.0; this->axis_of_IS = Vector3d( 1.0 , 0.0 , 0.0 ); } IS_Capt_Shrinkage::IS_Capt_Shrinkage( Vector3d center_of_IS_front , double radius_argument , Vector3d center_of_IS_rear ) { if( ( center_of_IS_front - center_of_IS_rear ).norm() == 0 ) { cout<<"( center_of_IS_front - center_of_IS_rear ).norm() == 0 "<<endl; cout<<" ERROR_ID = 5978134268 "<<endl; throw(""); } this->axis_of_IS = ( center_of_IS_front - center_of_IS_rear ) / ( center_of_IS_front - center_of_IS_rear ).norm(); // TODO Auto-generated constructor stub this->center_of_IS_front = center_of_IS_front; this->center_of_IS_rear = center_of_IS_rear; this->radius_of_IS = radius_argument; } IS_Capt_Shrinkage::IS_Capt_Shrinkage( Vector3d center_of_IS_front , double radius_argument , Vector3d center_of_IS_rear , Vector3d trap_arg ) { if( ( center_of_IS_front - center_of_IS_rear ).norm() == 0 ) { cout<<"( center_of_IS_front - center_of_IS_rear ).norm() == 0 "<<endl; cout<<" ERROR_ID = 5978134268 "<<endl; throw(""); } this->axis_of_IS = ( center_of_IS_front - center_of_IS_rear ) / ( center_of_IS_front - center_of_IS_rear ).norm(); // TODO Auto-generated constructor stub this->center_of_IS_front = center_of_IS_front; this->center_of_IS_rear = center_of_IS_rear; this->radius_of_IS = radius_argument; } //Copy constructor IS_Capt_Shrinkage::IS_Capt_Shrinkage( IS_Capt_Shrinkage& tmp ) { this->center_of_IS_front = tmp.get_center_of_IS_front(); this->center_of_IS_rear = tmp.center_of_IS_rear; this->radius_of_IS = tmp.get_radius_of_IS(); this->axis_of_IS = tmp.get_axis_of_IS(); } //Overloading the operator IS_Capt_Shrinkage IS_Capt_Shrinkage::operator=( const IS_Capt_Shrinkage& tmp ) { if( this == &tmp ) { cout<<" *this == &tmp "<<endl; throw(""); } this->center_of_IS_front = tmp.get_center_of_IS_front(); this->center_of_IS_rear = tmp.center_of_IS_rear; this->radius_of_IS = tmp.get_radius_of_IS(); this->axis_of_IS = tmp.get_axis_of_IS(); return *this; } //Gets the center of the front side of the IS Vector3d IS_Capt_Shrinkage::get_center_of_IS_front() const { return this->center_of_IS_front; } //Gets the center of the rear side of the IS Vector3d IS_Capt_Shrinkage::get_center_of_IS_rear() const { return this->center_of_IS_rear; } //Gets the radius of the IS double IS_Capt_Shrinkage::get_radius_of_IS() const { return this->radius_of_IS; } //Gets the axis of the IS Vector3d IS_Capt_Shrinkage::get_axis_of_IS() const { return this->axis_of_IS; } void IS_Capt_Shrinkage::set_center_of_IS_front( Vector3d center_argument_front ) { this->center_of_IS_front = center_argument_front; } void IS_Capt_Shrinkage::set_center_of_IS_rear( Vector3d center_argument_rear ) { this->center_of_IS_rear = center_argument_rear; } void IS_Capt_Shrinkage::set_radius_of_IS( double radius_center ) { this->radius_of_IS = radius_center; } void IS_Capt_Shrinkage::set_axis_of_IS( Vector3d axis_argument ) { this->axis_of_IS = axis_argument; } //Checks whether the segment intersect the IS bool IS_Capt_Shrinkage::check_IS_capture_shrinkage_caught_Main( Vector3d position ) { double radius_front = this->get_center_of_IS_front().norm(); double radius_back = this->get_center_of_IS_rear().norm(); if( ( position.norm() > radius_front ) && ( position.norm() < radius_back ) ) { double distance = distance_point_line( this->get_center_of_IS_front() , this->get_center_of_IS_rear() , position ); if( distance < this->get_radius_of_IS() ) { return true; } else { return false; } } else { return false; } } //Check whether the segment lies in the proximity of the IS bool IS_Capt_Shrinkage::check_IS_capture_segment_control( Vector3d first_point , Vector3d tangent ) { Vector3d center_of_IS = ( - 1.0 ) * this->axis_of_IS / this->axis_of_IS.norm() * Cell_parametres::A_AXIS; double distance = distance_point_segment( first_point , tangent , center_of_IS ); if( distance <= 3.5 * this->radius_of_IS ) { return true; } else { return false; } } IS_Capt_Shrinkage::~IS_Capt_Shrinkage() { // TODO Auto-generated destructor stub }
; A159915: a(n) = floor((n+1)/4)*floor(n/2). ; 0,0,0,1,2,2,3,6,8,8,10,15,18,18,21,28,32,32,36,45,50,50,55,66,72,72,78,91,98,98,105,120,128,128,136,153,162,162,171,190,200,200,210,231,242,242,253,276,288,288,300,325,338,338,351,378,392,392,406,435,450,450 mov $1,$0 div $0,2 add $1,1 div $1,4 mul $0,$1
_diff: file format elf32-i386 Disassembly of section .text: 00000000 <main>: char buf1[512], buf2[512]; int main(int argc, char *argv[]) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 57 push %edi e: 56 push %esi f: 53 push %ebx 10: 51 push %ecx 11: 83 ec 08 sub $0x8,%esp int fd0, fd1, n1, n2, i=0; if(argc <= 2){ 14: 83 39 02 cmpl $0x2,(%ecx) { 17: 8b 59 04 mov 0x4(%ecx),%ebx if(argc <= 2){ 1a: 7f 13 jg 2f <main+0x2f> printf(1, "need 2 argument"); 1c: 50 push %eax 1d: 50 push %eax 1e: 68 08 08 00 00 push $0x808 23: 6a 01 push $0x1 25: e8 86 04 00 00 call 4b0 <printf> exit(); 2a: e8 33 03 00 00 call 362 <exit> } if((fd0 = open(argv[1], O_RDWR)) < 0){ 2f: 50 push %eax 30: 50 push %eax 31: 6a 02 push $0x2 33: ff 73 04 pushl 0x4(%ebx) 36: e8 67 03 00 00 call 3a2 <open> 3b: 83 c4 10 add $0x10,%esp 3e: 85 c0 test %eax,%eax 40: 89 c6 mov %eax,%esi 42: 0f 88 81 00 00 00 js c9 <main+0xc9> printf(1, "cannot open %s\n", argv[1]); exit(); } if((fd1 = open(argv[2], O_RDWR)) < 0){ 48: 57 push %edi 49: 57 push %edi 4a: 6a 02 push $0x2 4c: ff 73 08 pushl 0x8(%ebx) 4f: e8 4e 03 00 00 call 3a2 <open> 54: 83 c4 10 add $0x10,%esp 57: 85 c0 test %eax,%eax 59: 89 c7 mov %eax,%edi 5b: 0f 88 89 00 00 00 js ea <main+0xea> printf(1, "cannot open %s\n", argv[2]); exit(); } while((n1 = read(fd0,buf1, sizeof(buf1))) > 0) { 61: 52 push %edx 62: 68 00 02 00 00 push $0x200 67: 68 40 0b 00 00 push $0xb40 6c: 56 push %esi 6d: e8 08 03 00 00 call 37a <read> 72: 83 c4 10 add $0x10,%esp 75: 85 c0 test %eax,%eax 77: 0f 8e 82 00 00 00 jle ff <main+0xff> if((n2 = read(fd1,buf2, sizeof(buf2))) > 0) { 7d: 53 push %ebx 7e: 68 00 02 00 00 push $0x200 83: 68 40 0d 00 00 push $0xd40 88: 57 push %edi 89: e8 ec 02 00 00 call 37a <read> 8e: 83 c4 10 add $0x10,%esp 91: 85 c0 test %eax,%eax 93: 7e cc jle 61 <main+0x61> if(n1 >0 && n2>0){ for(i = 0; i < n2; i++){ 95: 31 d2 xor %edx,%edx if(buf1[i] != buf2[i]){ 97: 0f b6 9a 40 0d 00 00 movzbl 0xd40(%edx),%ebx 9e: 38 9a 40 0b 00 00 cmp %bl,0xb40(%edx) a4: 74 38 je de <main+0xde> printf(1, "Files are different"); a6: 51 push %ecx a7: 51 push %ecx a8: 68 28 08 00 00 push $0x828 close(fd1); exit(); } } } printf(1, "Files are same"); ad: 6a 01 push $0x1 af: e8 fc 03 00 00 call 4b0 <printf> close(fd0); b4: 89 34 24 mov %esi,(%esp) b7: e8 ce 02 00 00 call 38a <close> close(fd1); bc: 89 3c 24 mov %edi,(%esp) bf: e8 c6 02 00 00 call 38a <close> exit(); c4: e8 99 02 00 00 call 362 <exit> printf(1, "cannot open %s\n", argv[1]); c9: 50 push %eax ca: ff 73 04 pushl 0x4(%ebx) cd: 68 18 08 00 00 push $0x818 d2: 6a 01 push $0x1 d4: e8 d7 03 00 00 call 4b0 <printf> exit(); d9: e8 84 02 00 00 call 362 <exit> for(i = 0; i < n2; i++){ de: 83 c2 01 add $0x1,%edx e1: 39 d0 cmp %edx,%eax e3: 75 b2 jne 97 <main+0x97> e5: e9 77 ff ff ff jmp 61 <main+0x61> printf(1, "cannot open %s\n", argv[2]); ea: 56 push %esi eb: ff 73 08 pushl 0x8(%ebx) ee: 68 18 08 00 00 push $0x818 f3: 6a 01 push $0x1 f5: e8 b6 03 00 00 call 4b0 <printf> exit(); fa: e8 63 02 00 00 call 362 <exit> printf(1, "Files are same"); ff: 50 push %eax 100: 50 push %eax 101: 68 3c 08 00 00 push $0x83c 106: eb a5 jmp ad <main+0xad> 108: 66 90 xchg %ax,%ax 10a: 66 90 xchg %ax,%ax 10c: 66 90 xchg %ax,%ax 10e: 66 90 xchg %ax,%ax 00000110 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 110: 55 push %ebp 111: 89 e5 mov %esp,%ebp 113: 53 push %ebx 114: 8b 45 08 mov 0x8(%ebp),%eax 117: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) 11a: 89 c2 mov %eax,%edx 11c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 120: 83 c1 01 add $0x1,%ecx 123: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 127: 83 c2 01 add $0x1,%edx 12a: 84 db test %bl,%bl 12c: 88 5a ff mov %bl,-0x1(%edx) 12f: 75 ef jne 120 <strcpy+0x10> ; return os; } 131: 5b pop %ebx 132: 5d pop %ebp 133: c3 ret 134: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 13a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000140 <strcmp>: int strcmp(const char *p, const char *q) { 140: 55 push %ebp 141: 89 e5 mov %esp,%ebp 143: 53 push %ebx 144: 8b 55 08 mov 0x8(%ebp),%edx 147: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 14a: 0f b6 02 movzbl (%edx),%eax 14d: 0f b6 19 movzbl (%ecx),%ebx 150: 84 c0 test %al,%al 152: 75 1c jne 170 <strcmp+0x30> 154: eb 2a jmp 180 <strcmp+0x40> 156: 8d 76 00 lea 0x0(%esi),%esi 159: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; 160: 83 c2 01 add $0x1,%edx while(*p && *p == *q) 163: 0f b6 02 movzbl (%edx),%eax p++, q++; 166: 83 c1 01 add $0x1,%ecx 169: 0f b6 19 movzbl (%ecx),%ebx while(*p && *p == *q) 16c: 84 c0 test %al,%al 16e: 74 10 je 180 <strcmp+0x40> 170: 38 d8 cmp %bl,%al 172: 74 ec je 160 <strcmp+0x20> return (uchar)*p - (uchar)*q; 174: 29 d8 sub %ebx,%eax } 176: 5b pop %ebx 177: 5d pop %ebp 178: c3 ret 179: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 180: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; 182: 29 d8 sub %ebx,%eax } 184: 5b pop %ebx 185: 5d pop %ebp 186: c3 ret 187: 89 f6 mov %esi,%esi 189: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000190 <strlen>: uint strlen(const char *s) { 190: 55 push %ebp 191: 89 e5 mov %esp,%ebp 193: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 196: 80 39 00 cmpb $0x0,(%ecx) 199: 74 15 je 1b0 <strlen+0x20> 19b: 31 d2 xor %edx,%edx 19d: 8d 76 00 lea 0x0(%esi),%esi 1a0: 83 c2 01 add $0x1,%edx 1a3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 1a7: 89 d0 mov %edx,%eax 1a9: 75 f5 jne 1a0 <strlen+0x10> ; return n; } 1ab: 5d pop %ebp 1ac: c3 ret 1ad: 8d 76 00 lea 0x0(%esi),%esi for(n = 0; s[n]; n++) 1b0: 31 c0 xor %eax,%eax } 1b2: 5d pop %ebp 1b3: c3 ret 1b4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 1ba: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 000001c0 <memset>: void* memset(void *dst, int c, uint n) { 1c0: 55 push %ebp 1c1: 89 e5 mov %esp,%ebp 1c3: 57 push %edi 1c4: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 1c7: 8b 4d 10 mov 0x10(%ebp),%ecx 1ca: 8b 45 0c mov 0xc(%ebp),%eax 1cd: 89 d7 mov %edx,%edi 1cf: fc cld 1d0: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 1d2: 89 d0 mov %edx,%eax 1d4: 5f pop %edi 1d5: 5d pop %ebp 1d6: c3 ret 1d7: 89 f6 mov %esi,%esi 1d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000001e0 <strchr>: char* strchr(const char *s, char c) { 1e0: 55 push %ebp 1e1: 89 e5 mov %esp,%ebp 1e3: 53 push %ebx 1e4: 8b 45 08 mov 0x8(%ebp),%eax 1e7: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) 1ea: 0f b6 10 movzbl (%eax),%edx 1ed: 84 d2 test %dl,%dl 1ef: 74 1d je 20e <strchr+0x2e> if(*s == c) 1f1: 38 d3 cmp %dl,%bl 1f3: 89 d9 mov %ebx,%ecx 1f5: 75 0d jne 204 <strchr+0x24> 1f7: eb 17 jmp 210 <strchr+0x30> 1f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 200: 38 ca cmp %cl,%dl 202: 74 0c je 210 <strchr+0x30> for(; *s; s++) 204: 83 c0 01 add $0x1,%eax 207: 0f b6 10 movzbl (%eax),%edx 20a: 84 d2 test %dl,%dl 20c: 75 f2 jne 200 <strchr+0x20> return (char*)s; return 0; 20e: 31 c0 xor %eax,%eax } 210: 5b pop %ebx 211: 5d pop %ebp 212: c3 ret 213: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 219: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000220 <gets>: char* gets(char *buf, int max) { 220: 55 push %ebp 221: 89 e5 mov %esp,%ebp 223: 57 push %edi 224: 56 push %esi 225: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 226: 31 f6 xor %esi,%esi 228: 89 f3 mov %esi,%ebx { 22a: 83 ec 1c sub $0x1c,%esp 22d: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 230: eb 2f jmp 261 <gets+0x41> 232: 8d b6 00 00 00 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 238: 8d 45 e7 lea -0x19(%ebp),%eax 23b: 83 ec 04 sub $0x4,%esp 23e: 6a 01 push $0x1 240: 50 push %eax 241: 6a 00 push $0x0 243: e8 32 01 00 00 call 37a <read> if(cc < 1) 248: 83 c4 10 add $0x10,%esp 24b: 85 c0 test %eax,%eax 24d: 7e 1c jle 26b <gets+0x4b> break; buf[i++] = c; 24f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 253: 83 c7 01 add $0x1,%edi 256: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 259: 3c 0a cmp $0xa,%al 25b: 74 23 je 280 <gets+0x60> 25d: 3c 0d cmp $0xd,%al 25f: 74 1f je 280 <gets+0x60> for(i=0; i+1 < max; ){ 261: 83 c3 01 add $0x1,%ebx 264: 3b 5d 0c cmp 0xc(%ebp),%ebx 267: 89 fe mov %edi,%esi 269: 7c cd jl 238 <gets+0x18> 26b: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 26d: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 270: c6 03 00 movb $0x0,(%ebx) } 273: 8d 65 f4 lea -0xc(%ebp),%esp 276: 5b pop %ebx 277: 5e pop %esi 278: 5f pop %edi 279: 5d pop %ebp 27a: c3 ret 27b: 90 nop 27c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 280: 8b 75 08 mov 0x8(%ebp),%esi 283: 8b 45 08 mov 0x8(%ebp),%eax 286: 01 de add %ebx,%esi 288: 89 f3 mov %esi,%ebx buf[i] = '\0'; 28a: c6 03 00 movb $0x0,(%ebx) } 28d: 8d 65 f4 lea -0xc(%ebp),%esp 290: 5b pop %ebx 291: 5e pop %esi 292: 5f pop %edi 293: 5d pop %ebp 294: c3 ret 295: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 299: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000002a0 <stat>: int stat(const char *n, struct stat *st) { 2a0: 55 push %ebp 2a1: 89 e5 mov %esp,%ebp 2a3: 56 push %esi 2a4: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 2a5: 83 ec 08 sub $0x8,%esp 2a8: 6a 00 push $0x0 2aa: ff 75 08 pushl 0x8(%ebp) 2ad: e8 f0 00 00 00 call 3a2 <open> if(fd < 0) 2b2: 83 c4 10 add $0x10,%esp 2b5: 85 c0 test %eax,%eax 2b7: 78 27 js 2e0 <stat+0x40> return -1; r = fstat(fd, st); 2b9: 83 ec 08 sub $0x8,%esp 2bc: ff 75 0c pushl 0xc(%ebp) 2bf: 89 c3 mov %eax,%ebx 2c1: 50 push %eax 2c2: e8 f3 00 00 00 call 3ba <fstat> close(fd); 2c7: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 2ca: 89 c6 mov %eax,%esi close(fd); 2cc: e8 b9 00 00 00 call 38a <close> return r; 2d1: 83 c4 10 add $0x10,%esp } 2d4: 8d 65 f8 lea -0x8(%ebp),%esp 2d7: 89 f0 mov %esi,%eax 2d9: 5b pop %ebx 2da: 5e pop %esi 2db: 5d pop %ebp 2dc: c3 ret 2dd: 8d 76 00 lea 0x0(%esi),%esi return -1; 2e0: be ff ff ff ff mov $0xffffffff,%esi 2e5: eb ed jmp 2d4 <stat+0x34> 2e7: 89 f6 mov %esi,%esi 2e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000002f0 <atoi>: int atoi(const char *s) { 2f0: 55 push %ebp 2f1: 89 e5 mov %esp,%ebp 2f3: 53 push %ebx 2f4: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 2f7: 0f be 11 movsbl (%ecx),%edx 2fa: 8d 42 d0 lea -0x30(%edx),%eax 2fd: 3c 09 cmp $0x9,%al n = 0; 2ff: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 304: 77 1f ja 325 <atoi+0x35> 306: 8d 76 00 lea 0x0(%esi),%esi 309: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 310: 8d 04 80 lea (%eax,%eax,4),%eax 313: 83 c1 01 add $0x1,%ecx 316: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while('0' <= *s && *s <= '9') 31a: 0f be 11 movsbl (%ecx),%edx 31d: 8d 5a d0 lea -0x30(%edx),%ebx 320: 80 fb 09 cmp $0x9,%bl 323: 76 eb jbe 310 <atoi+0x20> return n; } 325: 5b pop %ebx 326: 5d pop %ebp 327: c3 ret 328: 90 nop 329: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000330 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 330: 55 push %ebp 331: 89 e5 mov %esp,%ebp 333: 56 push %esi 334: 53 push %ebx 335: 8b 5d 10 mov 0x10(%ebp),%ebx 338: 8b 45 08 mov 0x8(%ebp),%eax 33b: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 33e: 85 db test %ebx,%ebx 340: 7e 14 jle 356 <memmove+0x26> 342: 31 d2 xor %edx,%edx 344: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 348: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 34c: 88 0c 10 mov %cl,(%eax,%edx,1) 34f: 83 c2 01 add $0x1,%edx while(n-- > 0) 352: 39 d3 cmp %edx,%ebx 354: 75 f2 jne 348 <memmove+0x18> return vdst; } 356: 5b pop %ebx 357: 5e pop %esi 358: 5d pop %ebp 359: c3 ret 0000035a <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 35a: b8 01 00 00 00 mov $0x1,%eax 35f: cd 40 int $0x40 361: c3 ret 00000362 <exit>: SYSCALL(exit) 362: b8 02 00 00 00 mov $0x2,%eax 367: cd 40 int $0x40 369: c3 ret 0000036a <wait>: SYSCALL(wait) 36a: b8 03 00 00 00 mov $0x3,%eax 36f: cd 40 int $0x40 371: c3 ret 00000372 <pipe>: SYSCALL(pipe) 372: b8 04 00 00 00 mov $0x4,%eax 377: cd 40 int $0x40 379: c3 ret 0000037a <read>: SYSCALL(read) 37a: b8 05 00 00 00 mov $0x5,%eax 37f: cd 40 int $0x40 381: c3 ret 00000382 <write>: SYSCALL(write) 382: b8 10 00 00 00 mov $0x10,%eax 387: cd 40 int $0x40 389: c3 ret 0000038a <close>: SYSCALL(close) 38a: b8 15 00 00 00 mov $0x15,%eax 38f: cd 40 int $0x40 391: c3 ret 00000392 <kill>: SYSCALL(kill) 392: b8 06 00 00 00 mov $0x6,%eax 397: cd 40 int $0x40 399: c3 ret 0000039a <exec>: SYSCALL(exec) 39a: b8 07 00 00 00 mov $0x7,%eax 39f: cd 40 int $0x40 3a1: c3 ret 000003a2 <open>: SYSCALL(open) 3a2: b8 0f 00 00 00 mov $0xf,%eax 3a7: cd 40 int $0x40 3a9: c3 ret 000003aa <mknod>: SYSCALL(mknod) 3aa: b8 11 00 00 00 mov $0x11,%eax 3af: cd 40 int $0x40 3b1: c3 ret 000003b2 <unlink>: SYSCALL(unlink) 3b2: b8 12 00 00 00 mov $0x12,%eax 3b7: cd 40 int $0x40 3b9: c3 ret 000003ba <fstat>: SYSCALL(fstat) 3ba: b8 08 00 00 00 mov $0x8,%eax 3bf: cd 40 int $0x40 3c1: c3 ret 000003c2 <link>: SYSCALL(link) 3c2: b8 13 00 00 00 mov $0x13,%eax 3c7: cd 40 int $0x40 3c9: c3 ret 000003ca <mkdir>: SYSCALL(mkdir) 3ca: b8 14 00 00 00 mov $0x14,%eax 3cf: cd 40 int $0x40 3d1: c3 ret 000003d2 <chdir>: SYSCALL(chdir) 3d2: b8 09 00 00 00 mov $0x9,%eax 3d7: cd 40 int $0x40 3d9: c3 ret 000003da <dup>: SYSCALL(dup) 3da: b8 0a 00 00 00 mov $0xa,%eax 3df: cd 40 int $0x40 3e1: c3 ret 000003e2 <getpid>: SYSCALL(getpid) 3e2: b8 0b 00 00 00 mov $0xb,%eax 3e7: cd 40 int $0x40 3e9: c3 ret 000003ea <sbrk>: SYSCALL(sbrk) 3ea: b8 0c 00 00 00 mov $0xc,%eax 3ef: cd 40 int $0x40 3f1: c3 ret 000003f2 <sleep>: SYSCALL(sleep) 3f2: b8 0d 00 00 00 mov $0xd,%eax 3f7: cd 40 int $0x40 3f9: c3 ret 000003fa <uptime>: SYSCALL(uptime) 3fa: b8 0e 00 00 00 mov $0xe,%eax 3ff: cd 40 int $0x40 401: c3 ret 00000402 <cps>: SYSCALL(cps) 402: b8 16 00 00 00 mov $0x16,%eax 407: cd 40 int $0x40 409: c3 ret 40a: 66 90 xchg %ax,%ax 40c: 66 90 xchg %ax,%ax 40e: 66 90 xchg %ax,%ax 00000410 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 410: 55 push %ebp 411: 89 e5 mov %esp,%ebp 413: 57 push %edi 414: 56 push %esi 415: 53 push %ebx 416: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 419: 85 d2 test %edx,%edx { 41b: 89 45 c0 mov %eax,-0x40(%ebp) neg = 1; x = -xx; 41e: 89 d0 mov %edx,%eax if(sgn && xx < 0){ 420: 79 76 jns 498 <printint+0x88> 422: f6 45 08 01 testb $0x1,0x8(%ebp) 426: 74 70 je 498 <printint+0x88> x = -xx; 428: f7 d8 neg %eax neg = 1; 42a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) } else { x = xx; } i = 0; 431: 31 f6 xor %esi,%esi 433: 8d 5d d7 lea -0x29(%ebp),%ebx 436: eb 0a jmp 442 <printint+0x32> 438: 90 nop 439: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi do{ buf[i++] = digits[x % base]; 440: 89 fe mov %edi,%esi 442: 31 d2 xor %edx,%edx 444: 8d 7e 01 lea 0x1(%esi),%edi 447: f7 f1 div %ecx 449: 0f b6 92 54 08 00 00 movzbl 0x854(%edx),%edx }while((x /= base) != 0); 450: 85 c0 test %eax,%eax buf[i++] = digits[x % base]; 452: 88 14 3b mov %dl,(%ebx,%edi,1) }while((x /= base) != 0); 455: 75 e9 jne 440 <printint+0x30> if(neg) 457: 8b 45 c4 mov -0x3c(%ebp),%eax 45a: 85 c0 test %eax,%eax 45c: 74 08 je 466 <printint+0x56> buf[i++] = '-'; 45e: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1) 463: 8d 7e 02 lea 0x2(%esi),%edi 466: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi 46a: 8b 7d c0 mov -0x40(%ebp),%edi 46d: 8d 76 00 lea 0x0(%esi),%esi 470: 0f b6 06 movzbl (%esi),%eax write(fd, &c, 1); 473: 83 ec 04 sub $0x4,%esp 476: 83 ee 01 sub $0x1,%esi 479: 6a 01 push $0x1 47b: 53 push %ebx 47c: 57 push %edi 47d: 88 45 d7 mov %al,-0x29(%ebp) 480: e8 fd fe ff ff call 382 <write> while(--i >= 0) 485: 83 c4 10 add $0x10,%esp 488: 39 de cmp %ebx,%esi 48a: 75 e4 jne 470 <printint+0x60> putc(fd, buf[i]); } 48c: 8d 65 f4 lea -0xc(%ebp),%esp 48f: 5b pop %ebx 490: 5e pop %esi 491: 5f pop %edi 492: 5d pop %ebp 493: c3 ret 494: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 498: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 49f: eb 90 jmp 431 <printint+0x21> 4a1: eb 0d jmp 4b0 <printf> 4a3: 90 nop 4a4: 90 nop 4a5: 90 nop 4a6: 90 nop 4a7: 90 nop 4a8: 90 nop 4a9: 90 nop 4aa: 90 nop 4ab: 90 nop 4ac: 90 nop 4ad: 90 nop 4ae: 90 nop 4af: 90 nop 000004b0 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 4b0: 55 push %ebp 4b1: 89 e5 mov %esp,%ebp 4b3: 57 push %edi 4b4: 56 push %esi 4b5: 53 push %ebx 4b6: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4b9: 8b 75 0c mov 0xc(%ebp),%esi 4bc: 0f b6 1e movzbl (%esi),%ebx 4bf: 84 db test %bl,%bl 4c1: 0f 84 b3 00 00 00 je 57a <printf+0xca> ap = (uint*)(void*)&fmt + 1; 4c7: 8d 45 10 lea 0x10(%ebp),%eax 4ca: 83 c6 01 add $0x1,%esi state = 0; 4cd: 31 ff xor %edi,%edi ap = (uint*)(void*)&fmt + 1; 4cf: 89 45 d4 mov %eax,-0x2c(%ebp) 4d2: eb 2f jmp 503 <printf+0x53> 4d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 4d8: 83 f8 25 cmp $0x25,%eax 4db: 0f 84 a7 00 00 00 je 588 <printf+0xd8> write(fd, &c, 1); 4e1: 8d 45 e2 lea -0x1e(%ebp),%eax 4e4: 83 ec 04 sub $0x4,%esp 4e7: 88 5d e2 mov %bl,-0x1e(%ebp) 4ea: 6a 01 push $0x1 4ec: 50 push %eax 4ed: ff 75 08 pushl 0x8(%ebp) 4f0: e8 8d fe ff ff call 382 <write> 4f5: 83 c4 10 add $0x10,%esp 4f8: 83 c6 01 add $0x1,%esi for(i = 0; fmt[i]; i++){ 4fb: 0f b6 5e ff movzbl -0x1(%esi),%ebx 4ff: 84 db test %bl,%bl 501: 74 77 je 57a <printf+0xca> if(state == 0){ 503: 85 ff test %edi,%edi c = fmt[i] & 0xff; 505: 0f be cb movsbl %bl,%ecx 508: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 50b: 74 cb je 4d8 <printf+0x28> state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 50d: 83 ff 25 cmp $0x25,%edi 510: 75 e6 jne 4f8 <printf+0x48> if(c == 'd'){ 512: 83 f8 64 cmp $0x64,%eax 515: 0f 84 05 01 00 00 je 620 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 51b: 81 e1 f7 00 00 00 and $0xf7,%ecx 521: 83 f9 70 cmp $0x70,%ecx 524: 74 72 je 598 <printf+0xe8> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 526: 83 f8 73 cmp $0x73,%eax 529: 0f 84 99 00 00 00 je 5c8 <printf+0x118> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 52f: 83 f8 63 cmp $0x63,%eax 532: 0f 84 08 01 00 00 je 640 <printf+0x190> putc(fd, *ap); ap++; } else if(c == '%'){ 538: 83 f8 25 cmp $0x25,%eax 53b: 0f 84 ef 00 00 00 je 630 <printf+0x180> write(fd, &c, 1); 541: 8d 45 e7 lea -0x19(%ebp),%eax 544: 83 ec 04 sub $0x4,%esp 547: c6 45 e7 25 movb $0x25,-0x19(%ebp) 54b: 6a 01 push $0x1 54d: 50 push %eax 54e: ff 75 08 pushl 0x8(%ebp) 551: e8 2c fe ff ff call 382 <write> 556: 83 c4 0c add $0xc,%esp 559: 8d 45 e6 lea -0x1a(%ebp),%eax 55c: 88 5d e6 mov %bl,-0x1a(%ebp) 55f: 6a 01 push $0x1 561: 50 push %eax 562: ff 75 08 pushl 0x8(%ebp) 565: 83 c6 01 add $0x1,%esi } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 568: 31 ff xor %edi,%edi write(fd, &c, 1); 56a: e8 13 fe ff ff call 382 <write> for(i = 0; fmt[i]; i++){ 56f: 0f b6 5e ff movzbl -0x1(%esi),%ebx write(fd, &c, 1); 573: 83 c4 10 add $0x10,%esp for(i = 0; fmt[i]; i++){ 576: 84 db test %bl,%bl 578: 75 89 jne 503 <printf+0x53> } } } 57a: 8d 65 f4 lea -0xc(%ebp),%esp 57d: 5b pop %ebx 57e: 5e pop %esi 57f: 5f pop %edi 580: 5d pop %ebp 581: c3 ret 582: 8d b6 00 00 00 00 lea 0x0(%esi),%esi state = '%'; 588: bf 25 00 00 00 mov $0x25,%edi 58d: e9 66 ff ff ff jmp 4f8 <printf+0x48> 592: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printint(fd, *ap, 16, 0); 598: 83 ec 0c sub $0xc,%esp 59b: b9 10 00 00 00 mov $0x10,%ecx 5a0: 6a 00 push $0x0 5a2: 8b 7d d4 mov -0x2c(%ebp),%edi 5a5: 8b 45 08 mov 0x8(%ebp),%eax 5a8: 8b 17 mov (%edi),%edx 5aa: e8 61 fe ff ff call 410 <printint> ap++; 5af: 89 f8 mov %edi,%eax 5b1: 83 c4 10 add $0x10,%esp state = 0; 5b4: 31 ff xor %edi,%edi ap++; 5b6: 83 c0 04 add $0x4,%eax 5b9: 89 45 d4 mov %eax,-0x2c(%ebp) 5bc: e9 37 ff ff ff jmp 4f8 <printf+0x48> 5c1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi s = (char*)*ap; 5c8: 8b 45 d4 mov -0x2c(%ebp),%eax 5cb: 8b 08 mov (%eax),%ecx ap++; 5cd: 83 c0 04 add $0x4,%eax 5d0: 89 45 d4 mov %eax,-0x2c(%ebp) if(s == 0) 5d3: 85 c9 test %ecx,%ecx 5d5: 0f 84 8e 00 00 00 je 669 <printf+0x1b9> while(*s != 0){ 5db: 0f b6 01 movzbl (%ecx),%eax state = 0; 5de: 31 ff xor %edi,%edi s = (char*)*ap; 5e0: 89 cb mov %ecx,%ebx while(*s != 0){ 5e2: 84 c0 test %al,%al 5e4: 0f 84 0e ff ff ff je 4f8 <printf+0x48> 5ea: 89 75 d0 mov %esi,-0x30(%ebp) 5ed: 89 de mov %ebx,%esi 5ef: 8b 5d 08 mov 0x8(%ebp),%ebx 5f2: 8d 7d e3 lea -0x1d(%ebp),%edi 5f5: 8d 76 00 lea 0x0(%esi),%esi write(fd, &c, 1); 5f8: 83 ec 04 sub $0x4,%esp s++; 5fb: 83 c6 01 add $0x1,%esi 5fe: 88 45 e3 mov %al,-0x1d(%ebp) write(fd, &c, 1); 601: 6a 01 push $0x1 603: 57 push %edi 604: 53 push %ebx 605: e8 78 fd ff ff call 382 <write> while(*s != 0){ 60a: 0f b6 06 movzbl (%esi),%eax 60d: 83 c4 10 add $0x10,%esp 610: 84 c0 test %al,%al 612: 75 e4 jne 5f8 <printf+0x148> 614: 8b 75 d0 mov -0x30(%ebp),%esi state = 0; 617: 31 ff xor %edi,%edi 619: e9 da fe ff ff jmp 4f8 <printf+0x48> 61e: 66 90 xchg %ax,%ax printint(fd, *ap, 10, 1); 620: 83 ec 0c sub $0xc,%esp 623: b9 0a 00 00 00 mov $0xa,%ecx 628: 6a 01 push $0x1 62a: e9 73 ff ff ff jmp 5a2 <printf+0xf2> 62f: 90 nop write(fd, &c, 1); 630: 83 ec 04 sub $0x4,%esp 633: 88 5d e5 mov %bl,-0x1b(%ebp) 636: 8d 45 e5 lea -0x1b(%ebp),%eax 639: 6a 01 push $0x1 63b: e9 21 ff ff ff jmp 561 <printf+0xb1> putc(fd, *ap); 640: 8b 7d d4 mov -0x2c(%ebp),%edi write(fd, &c, 1); 643: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 646: 8b 07 mov (%edi),%eax write(fd, &c, 1); 648: 6a 01 push $0x1 ap++; 64a: 83 c7 04 add $0x4,%edi putc(fd, *ap); 64d: 88 45 e4 mov %al,-0x1c(%ebp) write(fd, &c, 1); 650: 8d 45 e4 lea -0x1c(%ebp),%eax 653: 50 push %eax 654: ff 75 08 pushl 0x8(%ebp) 657: e8 26 fd ff ff call 382 <write> ap++; 65c: 89 7d d4 mov %edi,-0x2c(%ebp) 65f: 83 c4 10 add $0x10,%esp state = 0; 662: 31 ff xor %edi,%edi 664: e9 8f fe ff ff jmp 4f8 <printf+0x48> s = "(null)"; 669: bb 4b 08 00 00 mov $0x84b,%ebx while(*s != 0){ 66e: b8 28 00 00 00 mov $0x28,%eax 673: e9 72 ff ff ff jmp 5ea <printf+0x13a> 678: 66 90 xchg %ax,%ax 67a: 66 90 xchg %ax,%ax 67c: 66 90 xchg %ax,%ax 67e: 66 90 xchg %ax,%ax 00000680 <free>: static Header base; static Header *freep; void free(void *ap) { 680: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 681: a1 20 0b 00 00 mov 0xb20,%eax { 686: 89 e5 mov %esp,%ebp 688: 57 push %edi 689: 56 push %esi 68a: 53 push %ebx 68b: 8b 5d 08 mov 0x8(%ebp),%ebx bp = (Header*)ap - 1; 68e: 8d 4b f8 lea -0x8(%ebx),%ecx 691: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 698: 39 c8 cmp %ecx,%eax 69a: 8b 10 mov (%eax),%edx 69c: 73 32 jae 6d0 <free+0x50> 69e: 39 d1 cmp %edx,%ecx 6a0: 72 04 jb 6a6 <free+0x26> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 6a2: 39 d0 cmp %edx,%eax 6a4: 72 32 jb 6d8 <free+0x58> break; if(bp + bp->s.size == p->s.ptr){ 6a6: 8b 73 fc mov -0x4(%ebx),%esi 6a9: 8d 3c f1 lea (%ecx,%esi,8),%edi 6ac: 39 fa cmp %edi,%edx 6ae: 74 30 je 6e0 <free+0x60> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 6b0: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 6b3: 8b 50 04 mov 0x4(%eax),%edx 6b6: 8d 34 d0 lea (%eax,%edx,8),%esi 6b9: 39 f1 cmp %esi,%ecx 6bb: 74 3a je 6f7 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 6bd: 89 08 mov %ecx,(%eax) freep = p; 6bf: a3 20 0b 00 00 mov %eax,0xb20 } 6c4: 5b pop %ebx 6c5: 5e pop %esi 6c6: 5f pop %edi 6c7: 5d pop %ebp 6c8: c3 ret 6c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 6d0: 39 d0 cmp %edx,%eax 6d2: 72 04 jb 6d8 <free+0x58> 6d4: 39 d1 cmp %edx,%ecx 6d6: 72 ce jb 6a6 <free+0x26> { 6d8: 89 d0 mov %edx,%eax 6da: eb bc jmp 698 <free+0x18> 6dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp->s.size += p->s.ptr->s.size; 6e0: 03 72 04 add 0x4(%edx),%esi 6e3: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 6e6: 8b 10 mov (%eax),%edx 6e8: 8b 12 mov (%edx),%edx 6ea: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 6ed: 8b 50 04 mov 0x4(%eax),%edx 6f0: 8d 34 d0 lea (%eax,%edx,8),%esi 6f3: 39 f1 cmp %esi,%ecx 6f5: 75 c6 jne 6bd <free+0x3d> p->s.size += bp->s.size; 6f7: 03 53 fc add -0x4(%ebx),%edx freep = p; 6fa: a3 20 0b 00 00 mov %eax,0xb20 p->s.size += bp->s.size; 6ff: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 702: 8b 53 f8 mov -0x8(%ebx),%edx 705: 89 10 mov %edx,(%eax) } 707: 5b pop %ebx 708: 5e pop %esi 709: 5f pop %edi 70a: 5d pop %ebp 70b: c3 ret 70c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000710 <malloc>: return freep; } void* malloc(uint nbytes) { 710: 55 push %ebp 711: 89 e5 mov %esp,%ebp 713: 57 push %edi 714: 56 push %esi 715: 53 push %ebx 716: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 719: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 71c: 8b 15 20 0b 00 00 mov 0xb20,%edx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 722: 8d 78 07 lea 0x7(%eax),%edi 725: c1 ef 03 shr $0x3,%edi 728: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 72b: 85 d2 test %edx,%edx 72d: 0f 84 9d 00 00 00 je 7d0 <malloc+0xc0> 733: 8b 02 mov (%edx),%eax 735: 8b 48 04 mov 0x4(%eax),%ecx base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 738: 39 cf cmp %ecx,%edi 73a: 76 6c jbe 7a8 <malloc+0x98> 73c: 81 ff 00 10 00 00 cmp $0x1000,%edi 742: bb 00 10 00 00 mov $0x1000,%ebx 747: 0f 43 df cmovae %edi,%ebx p = sbrk(nu * sizeof(Header)); 74a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi 751: eb 0e jmp 761 <malloc+0x51> 753: 90 nop 754: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 758: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 75a: 8b 48 04 mov 0x4(%eax),%ecx 75d: 39 f9 cmp %edi,%ecx 75f: 73 47 jae 7a8 <malloc+0x98> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 761: 39 05 20 0b 00 00 cmp %eax,0xb20 767: 89 c2 mov %eax,%edx 769: 75 ed jne 758 <malloc+0x48> p = sbrk(nu * sizeof(Header)); 76b: 83 ec 0c sub $0xc,%esp 76e: 56 push %esi 76f: e8 76 fc ff ff call 3ea <sbrk> if(p == (char*)-1) 774: 83 c4 10 add $0x10,%esp 777: 83 f8 ff cmp $0xffffffff,%eax 77a: 74 1c je 798 <malloc+0x88> hp->s.size = nu; 77c: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 77f: 83 ec 0c sub $0xc,%esp 782: 83 c0 08 add $0x8,%eax 785: 50 push %eax 786: e8 f5 fe ff ff call 680 <free> return freep; 78b: 8b 15 20 0b 00 00 mov 0xb20,%edx if((p = morecore(nunits)) == 0) 791: 83 c4 10 add $0x10,%esp 794: 85 d2 test %edx,%edx 796: 75 c0 jne 758 <malloc+0x48> return 0; } } 798: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 79b: 31 c0 xor %eax,%eax } 79d: 5b pop %ebx 79e: 5e pop %esi 79f: 5f pop %edi 7a0: 5d pop %ebp 7a1: c3 ret 7a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(p->s.size == nunits) 7a8: 39 cf cmp %ecx,%edi 7aa: 74 54 je 800 <malloc+0xf0> p->s.size -= nunits; 7ac: 29 f9 sub %edi,%ecx 7ae: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 7b1: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 7b4: 89 78 04 mov %edi,0x4(%eax) freep = prevp; 7b7: 89 15 20 0b 00 00 mov %edx,0xb20 } 7bd: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); 7c0: 83 c0 08 add $0x8,%eax } 7c3: 5b pop %ebx 7c4: 5e pop %esi 7c5: 5f pop %edi 7c6: 5d pop %ebp 7c7: c3 ret 7c8: 90 nop 7c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; 7d0: c7 05 20 0b 00 00 24 movl $0xb24,0xb20 7d7: 0b 00 00 7da: c7 05 24 0b 00 00 24 movl $0xb24,0xb24 7e1: 0b 00 00 base.s.size = 0; 7e4: b8 24 0b 00 00 mov $0xb24,%eax 7e9: c7 05 28 0b 00 00 00 movl $0x0,0xb28 7f0: 00 00 00 7f3: e9 44 ff ff ff jmp 73c <malloc+0x2c> 7f8: 90 nop 7f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi prevp->s.ptr = p->s.ptr; 800: 8b 08 mov (%eax),%ecx 802: 89 0a mov %ecx,(%edx) 804: eb b1 jmp 7b7 <malloc+0xa7>
; A298031: Coordination sequence of Dual(3.4.6.4) tiling with respect to a tetravalent node. ; 1,4,10,16,30,36,48,54,66,72,84,90,102,108,120,126,138,144,156,162,174,180,192,198,210,216,228,234,246,252,264,270,282,288,300,306,318,324,336,342,354,360,372,378,390,396,408,414,426,432,444,450,462,468,480,486,498,504,516,522,534,540,552,558,570,576,588,594,606,612,624,630,642,648,660,666,678,684,696,702,714,720,732,738,750,756,768,774,786,792,804,810,822,828,840,846,858,864,876,882,894,900,912,918,930,936,948,954,966,972,984,990,1002,1008,1020,1026,1038,1044,1056,1062,1074,1080,1092,1098,1110,1116,1128,1134,1146,1152,1164,1170,1182,1188,1200,1206,1218,1224,1236,1242,1254,1260,1272,1278,1290,1296,1308,1314,1326,1332,1344,1350,1362,1368,1380,1386,1398,1404,1416,1422,1434,1440,1452,1458,1470,1476,1488,1494,1506,1512,1524,1530,1542,1548,1560,1566,1578,1584,1596,1602,1614,1620,1632,1638,1650,1656,1668,1674,1686,1692,1704,1710,1722,1728,1740,1746,1758,1764,1776,1782,1794,1800,1812,1818,1830,1836,1848,1854,1866,1872,1884,1890,1902,1908,1920,1926,1938,1944,1956,1962,1974,1980,1992,1998,2010,2016,2028,2034,2046,2052,2064,2070,2082,2088,2100,2106,2118,2124,2136,2142,2154,2160,2172,2178,2190,2196,2208,2214,2226,2232 mov $3,$0 mov $4,$0 trn $0,3 mul $3,2 mov $1,$3 mov $2,2 lpb $0 sub $0,1 trn $0,1 trn $2,1 add $1,$2 add $1,3 lpe mul $1,2 trn $1,3 lpb $4 add $1,2 sub $4,1 lpe add $1,1
; ; Tape save routine ; ; Stefano 31/5/2010 ; ; int __CALLEE__ tape_save_block_callee(void *addr, size_t len, unsigned char type) XLIB tape_save_block_callee XDEF ASMDISP_TAPE_SAVE_BLOCK_CALLEE .tape_save_block_callee pop ix pop bc pop de pop hl push ix ; enter : hl = addr ; de = len ; c = type .asmentry jp $1820 DEFC ASMDISP_TAPE_SAVE_BLOCK_CALLEE = asmentry - tape_save_block_callee
Dump of assembler code for function main: => 0x000055555556f950 <+0>: push %r15 0x000055555556f952 <+2>: mov $0x1,%ecx 0x000055555556f957 <+7>: push %r14 0x000055555556f959 <+9>: push %r13 0x000055555556f95b <+11>: push %r12 0x000055555556f95d <+13>: push %rbp 0x000055555556f95e <+14>: push %rbx 0x000055555556f95f <+15>: sub $0x688,%rsp 0x000055555556f966 <+22>: mov %edi,0xbc(%rsp) 0x000055555556f96d <+29>: lea 0xb0(%rsp),%rdx 0x000055555556f975 <+37>: lea 0xd0(%rsp),%r15 0x000055555556f97d <+45>: mov %rsi,0xb0(%rsp) 0x000055555556f985 <+53>: lea 0xbc(%rsp),%rsi 0x000055555556f98d <+61>: mov %fs:0x28,%rax 0x000055555556f996 <+70>: mov %rax,0x678(%rsp) 0x000055555556f99e <+78>: xor %eax,%eax 0x000055555556f9a0 <+80>: lea 0x2b0(%rsp),%rax 0x000055555556f9a8 <+88>: mov %rax,0x8(%rsp) 0x000055555556f9ad <+93>: mov %rax,%rdi 0x000055555556f9b0 <+96>: call *0x2731a(%rip) # 0x555555596cd0 0x000055555556f9b6 <+102>: mov 0x266f3(%rip),%rax # 0x5555555960b0 0x000055555556f9bd <+109>: mov %r15,%rdi 0x000055555556f9c0 <+112>: movb $0x1,(%rax) 0x000055555556f9c3 <+115>: call *0x268ff(%rip) # 0x5555555962c8 0x000055555556f9c9 <+121>: call 0x555555588c40 0x000055555556f9ce <+126>: call *0x26cbc(%rip) # 0x555555596690 0x000055555556f9d4 <+132>: call *0x2710e(%rip) # 0x555555596ae8 0x000055555556f9da <+138>: call *0x26790(%rip) # 0x555555596170 0x000055555556f9e0 <+144>: call *0x267a2(%rip) # 0x555555596188 0x000055555556f9e6 <+150>: call *0x275dc(%rip) # 0x555555596fc8 0x000055555556f9ec <+156>: call *0x27256(%rip) # 0x555555596c48 0x000055555556f9f2 <+162>: call *0x27370(%rip) # 0x555555596d68 0x000055555556f9f8 <+168>: call *0x275ba(%rip) # 0x555555596fb8 0x000055555556f9fe <+174>: call *0x26dd4(%rip) # 0x5555555967d8 0x000055555556fa04 <+180>: call *0x26a26(%rip) # 0x555555596430 0x000055555556fa0a <+186>: call *0x266b0(%rip) # 0x5555555960c0 0x000055555556fa10 <+192>: call *0x2734a(%rip) # 0x555555596d60 0x000055555556fa16 <+198>: call *0x26a84(%rip) # 0x5555555964a0 0x000055555556fa1c <+204>: call *0x273de(%rip) # 0x555555596e00 0x000055555556fa22 <+210>: call *0x26b38(%rip) # 0x555555596560 0x000055555556fa28 <+216>: call *0x266ba(%rip) # 0x5555555960e8 0x000055555556fa2e <+222>: call *0x26614(%rip) # 0x555555596048 0x000055555556fa34 <+228>: call *0x26c16(%rip) # 0x555555596650 0x000055555556fa3a <+234>: call *0x27348(%rip) # 0x555555596d88 0x000055555556fa40 <+240>: call *0x273ea(%rip) # 0x555555596e30 0x000055555556fa46 <+246>: call *0x269cc(%rip) # 0x555555596418 0x000055555556fa4c <+252>: call *0x2733e(%rip) # 0x555555596d90 0x000055555556fa52 <+258>: call *0x26e08(%rip) # 0x555555596860 0x000055555556fa58 <+264>: call *0x2728a(%rip) # 0x555555596ce8 0x000055555556fa5e <+270>: call *0x26e84(%rip) # 0x5555555968e8 0x000055555556fa64 <+276>: call *0x27426(%rip) # 0x555555596e90 0x000055555556fa6a <+282>: call *0x26d58(%rip) # 0x5555555967c8 0x000055555556fa70 <+288>: call *0x274f2(%rip) # 0x555555596f68 0x000055555556fa76 <+294>: call *0x26fec(%rip) # 0x555555596a68 0x000055555556fa7c <+300>: call *0x26ede(%rip) # 0x555555596960 0x000055555556fa82 <+306>: call *0x27200(%rip) # 0x555555596c88 0x000055555556fa88 <+312>: call *0x26cc2(%rip) # 0x555555596750 0x000055555556fa8e <+318>: call *0x26ad4(%rip) # 0x555555596568 0x000055555556fa94 <+324>: call *0x269b6(%rip) # 0x555555596450 0x000055555556fa9a <+330>: call *0x27028(%rip) # 0x555555596ac8 0x000055555556faa0 <+336>: call *0x2657a(%rip) # 0x555555596020 0x000055555556faa6 <+342>: call *0x26f04(%rip) # 0x5555555969b0 0x000055555556faac <+348>: call *0x27136(%rip) # 0x555555596be8 0x000055555556fab2 <+354>: call *0x26830(%rip) # 0x5555555962e8 0x000055555556fab8 <+360>: call *0x26f2a(%rip) # 0x5555555969e8 0x000055555556fabe <+366>: call *0x267bc(%rip) # 0x555555596280 0x000055555556fac4 <+372>: call *0x2712e(%rip) # 0x555555596bf8 0x000055555556faca <+378>: call *0x270c8(%rip) # 0x555555596b98 0x000055555556fad0 <+384>: call *0x26bd2(%rip) # 0x5555555966a8 0x000055555556fad6 <+390>: call *0x26ce4(%rip) # 0x5555555967c0 0x000055555556fadc <+396>: call *0x26986(%rip) # 0x555555596468 0x000055555556fae2 <+402>: call *0x26f48(%rip) # 0x555555596a30 0x000055555556fae8 <+408>: call *0x269c2(%rip) # 0x5555555964b0 0x000055555556faee <+414>: call *0x27024(%rip) # 0x555555596b18 0x000055555556faf4 <+420>: call *0x26f7e(%rip) # 0x555555596a78 0x000055555556fafa <+426>: mov %rax,%rbp 0x000055555556fafd <+429>: mov %rax,%rdi 0x000055555556fb00 <+432>: call *0x27492(%rip) # 0x555555596f98 0x000055555556fb06 <+438>: mov %rbp,%rdi 0x000055555556fb09 <+441>: call *0x26f89(%rip) # 0x555555596a98 0x000055555556fb0f <+447>: mov %rbp,%rdi 0x000055555556fb12 <+450>: call *0x267a0(%rip) # 0x5555555962b8 0x000055555556fb18 <+456>: mov %rbp,%rdi 0x000055555556fb1b <+459>: call *0x27407(%rip) # 0x555555596f28 0x000055555556fb21 <+465>: mov %rbp,%rdi 0x000055555556fb24 <+468>: call *0x274be(%rip) # 0x555555596fe8 0x000055555556fb2a <+474>: mov %rbp,%rdi 0x000055555556fb2d <+477>: call *0x26a0d(%rip) # 0x555555596540 0x000055555556fb33 <+483>: mov %rbp,%rdi 0x000055555556fb36 <+486>: call *0x2668c(%rip) # 0x5555555961c8 0x000055555556fb3c <+492>: mov %rbp,%rdi 0x000055555556fb3f <+495>: call *0x26ee3(%rip) # 0x555555596a28 0x000055555556fb45 <+501>: mov %rbp,%rdi 0x000055555556fb48 <+504>: call *0x2668a(%rip) # 0x5555555961d8 0x000055555556fb4e <+510>: mov %rbp,%rdi 0x000055555556fb51 <+513>: call *0x26659(%rip) # 0x5555555961b0 0x000055555556fb57 <+519>: mov %rbp,%rdi 0x000055555556fb5a <+522>: call *0x26e70(%rip) # 0x5555555969d0 0x000055555556fb60 <+528>: mov %rbp,%rdi 0x000055555556fb63 <+531>: call *0x270c7(%rip) # 0x555555596c30 0x000055555556fb69 <+537>: mov %rbp,%rdi 0x000055555556fb6c <+540>: call *0x268b6(%rip) # 0x555555596428 0x000055555556fb72 <+546>: mov %rbp,%rdi 0x000055555556fb75 <+549>: call *0x2696d(%rip) # 0x5555555964e8 0x000055555556fb7b <+555>: mov %rbp,%rdi 0x000055555556fb7e <+558>: call *0x26584(%rip) # 0x555555596108 0x000055555556fb84 <+564>: mov %rbp,%rdi 0x000055555556fb87 <+567>: call *0x26dab(%rip) # 0x555555596938 0x000055555556fb8d <+573>: mov %rbp,%rdi 0x000055555556fb90 <+576>: call *0x26b22(%rip) # 0x5555555966b8 0x000055555556fb96 <+582>: mov %rbp,%rdi 0x000055555556fb99 <+585>: call *0x27181(%rip) # 0x555555596d20 0x000055555556fb9f <+591>: mov %rbp,%rdi 0x000055555556fba2 <+594>: call *0x26c98(%rip) # 0x555555596840 0x000055555556fba8 <+600>: mov %rbp,%rdi 0x000055555556fbab <+603>: call *0x26507(%rip) # 0x5555555960b8 0x000055555556fbb1 <+609>: mov %rbp,%rdi 0x000055555556fbb4 <+612>: call *0x2655e(%rip) # 0x555555596118 0x000055555556fbba <+618>: mov %rbp,%rdi 0x000055555556fbbd <+621>: call *0x2693d(%rip) # 0x555555596500 0x000055555556fbc3 <+627>: mov %rbp,%rdi 0x000055555556fbc6 <+630>: call *0x273ac(%rip) # 0x555555596f78 0x000055555556fbcc <+636>: mov %rbp,%rdi 0x000055555556fbcf <+639>: call *0x26653(%rip) # 0x555555596228 0x000055555556fbd5 <+645>: mov %rbp,%rdi 0x000055555556fbd8 <+648>: call *0x269e2(%rip) # 0x5555555965c0 0x000055555556fbde <+654>: mov %rbp,%rdi 0x000055555556fbe1 <+657>: call *0x26ce1(%rip) # 0x5555555968c8 0x000055555556fbe7 <+663>: mov %rbp,%rdi 0x000055555556fbea <+666>: call *0x273a0(%rip) # 0x555555596f90 0x000055555556fbf0 <+672>: mov %rbp,%rdi 0x000055555556fbf3 <+675>: call *0x26447(%rip) # 0x555555596040 0x000055555556fbf9 <+681>: mov %rbp,%rdi 0x000055555556fbfc <+684>: call *0x2720e(%rip) # 0x555555596e10 0x000055555556fc02 <+690>: mov %rbp,%rdi 0x000055555556fc05 <+693>: call *0x271ed(%rip) # 0x555555596df8 0x000055555556fc0b <+699>: mov %rbp,%rdi 0x000055555556fc0e <+702>: call *0x26bd4(%rip) # 0x5555555967e8 0x000055555556fc14 <+708>: mov %rbp,%rdi 0x000055555556fc17 <+711>: call *0x26d7b(%rip) # 0x555555596998 0x000055555556fc1d <+717>: mov %rbp,%rdi 0x000055555556fc20 <+720>: call *0x26722(%rip) # 0x555555596348 0x000055555556fc26 <+726>: mov %rbp,%rdi 0x000055555556fc29 <+729>: call *0x273b1(%rip) # 0x555555596fe0 0x000055555556fc2f <+735>: sub $0x8,%rsp 0x000055555556fc33 <+739>: xor %r9d,%r9d 0x000055555556fc36 <+742>: xor %r8d,%r8d 0x000055555556fc39 <+745>: push $0x0 0x000055555556fc3b <+747>: lea 0x1f32e(%rip),%rdx # 0x55555558ef70 0x000055555556fc42 <+754>: mov 0xcc(%rsp),%edi 0x000055555556fc49 <+761>: mov $0x37,%ecx 0x000055555556fc4e <+766>: mov 0xc0(%rsp),%rsi 0x000055555556fc56 <+774>: call *0x26614(%rip) # 0x555555596270 0x000055555556fc5c <+780>: cmpb $0x0,0x2985d(%rip) # 0x5555555994c0 0x000055555556fc63 <+787>: pop %r9 0x000055555556fc65 <+789>: pop %r10 0x000055555556fc67 <+791>: je 0x55555556fc76 <main+806> 0x000055555556fc69 <+793>: cmpb $0x0,0x2ad30(%rip) # 0x55555559a9a0 0x000055555556fc70 <+800>: jne 0x555555570adf <main+4495> 0x000055555556fc76 <+806>: mov 0xb0(%rsp),%rax 0x000055555556fc7e <+814>: xor %edx,%edx 0x000055555556fc80 <+816>: mov (%rax),%rbp 0x000055555556fc83 <+819>: test %rbp,%rbp 0x000055555556fc86 <+822>: je 0x55555556fc94 <main+836> 0x000055555556fc88 <+824>: mov %rbp,%rdi 0x000055555556fc8b <+827>: call *0x265d7(%rip) # 0x555555596268 0x000055555556fc91 <+833>: mov %rax,%rdx 0x000055555556fc94 <+836>: cmpb $0x0,0x28f65(%rip) # 0x555555598c00 0x000055555556fc9b <+843>: jne 0x5555555708e3 <main+3987> 0x000055555556fca1 <+849>: lea 0x530(%rsp),%rax 0x000055555556fca9 <+857>: mov %r15,%rdi 0x000055555556fcac <+860>: movq $0x0,0x510(%rsp) 0x000055555556fcb8 <+872>: movzbl 0x290c1(%rip),%esi # 0x555555598d80 0x000055555556fcbf <+879>: mov %rax,0x520(%rsp) 0x000055555556fcc7 <+887>: lea 0x560(%rsp),%rax 0x000055555556fccf <+895>: mov %rax,0x550(%rsp) 0x000055555556fcd7 <+903>: lea 0x580(%rsp),%rax 0x000055555556fcdf <+911>: mov %rax,0x570(%rsp) 0x000055555556fce7 <+919>: lea 0x5b8(%rsp),%rax 0x000055555556fcef <+927>: mov %rax,0x5a8(%rsp) 0x000055555556fcf7 <+935>: movabs $0x400000000,%rax 0x000055555556fd01 <+945>: movq $0x0,0x518(%rsp) 0x000055555556fd0d <+957>: movq $0x0,0x528(%rsp) 0x000055555556fd19 <+969>: movb $0x0,0x530(%rsp) 0x000055555556fd21 <+977>: movq $0x0,0x540(%rsp) 0x000055555556fd2d <+989>: movl $0x0,0x548(%rsp) 0x000055555556fd38 <+1000>: movq $0x0,0x558(%rsp) 0x000055555556fd44 <+1012>: movb $0x0,0x560(%rsp) 0x000055555556fd4c <+1020>: movq $0x0,0x578(%rsp) 0x000055555556fd58 <+1032>: movb $0x0,0x580(%rsp) 0x000055555556fd60 <+1040>: movq $0x0,0x590(%rsp) 0x000055555556fd6c <+1052>: movq $0x0,0x598(%rsp) 0x000055555556fd78 <+1064>: movq $0x0,0x5a0(%rsp) 0x000055555556fd84 <+1076>: mov %rax,0x5b0(%rsp) 0x000055555556fd8c <+1084>: call *0x26a16(%rip) # 0x5555555967a8 0x000055555556fd92 <+1090>: cmpb $0x0,0x2a5c7(%rip) # 0x55555559a360 0x000055555556fd99 <+1097>: je 0x5555555708f7 <main+4007> 0x000055555556fd9f <+1103>: movzbl 0x28bda(%rip),%ecx # 0x555555598980 0x000055555556fda6 <+1110>: mov 0x2881b(%rip),%rdx # 0x5555555985c8 0x000055555556fdad <+1117>: lea 0x180(%rsp),%rbx 0x000055555556fdb5 <+1125>: mov 0x28b05(%rip),%esi # 0x5555555988c0 0x000055555556fdbb <+1131>: mov %rbx,0x20(%rsp) 0x000055555556fdc0 <+1136>: mov %rbx,%rdi 0x000055555556fdc3 <+1139>: mov 0x287f6(%rip),%rax # 0x5555555985c0 0x000055555556fdca <+1146>: mov 0x288ef(%rip),%r8 # 0x5555555986c0 0x000055555556fdd1 <+1153>: push %rsi 0x000055555556fdd2 <+1154>: mov 0x288ef(%rip),%r9 # 0x5555555986c8 0x000055555556fdd9 <+1161>: mov %r15,%rsi 0x000055555556fddc <+1164>: push %rcx 0x000055555556fddd <+1165>: mov 0x289e4(%rip),%rcx # 0x5555555987c8 0x000055555556fde4 <+1172>: push %rdx 0x000055555556fde5 <+1173>: mov 0x289d4(%rip),%rdx # 0x5555555987c0 0x000055555556fdec <+1180>: push %rax 0x000055555556fded <+1181>: call *0x26715(%rip) # 0x555555596508 0x000055555556fdf3 <+1187>: add $0x20,%rsp 0x000055555556fdf7 <+1191>: testb $0x1,0x188(%rsp) 0x000055555556fdff <+1199>: je 0x55555556ff29 <main+1497> 0x000055555556fe05 <+1205>: mov 0x180(%rsp),%rbx 0x000055555556fe0d <+1213>: movq $0x0,0x180(%rsp) 0x000055555556fe19 <+1225>: test %rbx,%rbx 0x000055555556fe1c <+1228>: je 0x55555556ff29 <main+1497> 0x000055555556fe22 <+1234>: call *0x265b0(%rip) # 0x5555555963d8 0x000055555556fe28 <+1240>: lea 0x140(%rsp),%r14 0x000055555556fe30 <+1248>: lea 0x420(%rsp),%rdi 0x000055555556fe38 <+1256>: mov %rbx,0x140(%rsp) 0x000055555556fe40 <+1264>: mov %rax,%rbp 0x000055555556fe43 <+1267>: mov %r14,%rsi 0x000055555556fe46 <+1270>: call 0x555555578a40 0x000055555556fe4b <+1275>: mov %rbp,%rdi 0x000055555556fe4e <+1278>: mov 0x428(%rsp),%rdx 0x000055555556fe56 <+1286>: mov 0x420(%rsp),%rsi 0x000055555556fe5e <+1294>: call *0x26c6c(%rip) # 0x555555596ad0 0x000055555556fe64 <+1300>: mov %rax,%rdi 0x000055555556fe67 <+1303>: mov 0x18(%rax),%rax 0x000055555556fe6b <+1307>: cmp %rax,0x10(%rdi) 0x000055555556fe6f <+1311>: jbe 0x555555570d74 <main+5156> 0x000055555556fe75 <+1317>: lea 0x1(%rax),%rdx 0x000055555556fe79 <+1321>: mov %rdx,0x18(%rdi) 0x000055555556fe7d <+1325>: movb $0xa,(%rax) 0x000055555556fe80 <+1328>: mov 0x420(%rsp),%rdi 0x000055555556fe88 <+1336>: lea 0x430(%rsp),%rax 0x000055555556fe90 <+1344>: cmp %rax,%rdi 0x000055555556fe93 <+1347>: je 0x55555556fea7 <main+1367> 0x000055555556fe95 <+1349>: mov 0x430(%rsp),%rax 0x000055555556fe9d <+1357>: lea 0x1(%rax),%rsi 0x000055555556fea1 <+1361>: call *0x261e9(%rip) # 0x555555596090 0x000055555556fea7 <+1367>: mov 0x140(%rsp),%rdi 0x000055555556feaf <+1375>: test %rdi,%rdi 0x000055555556feb2 <+1378>: je 0x55555556feba <main+1386> 0x000055555556feb4 <+1380>: mov (%rdi),%rax 0x000055555556feb7 <+1383>: call *0x8(%rax) 0x000055555556feba <+1386>: lea 0x510(%rsp),%rax 0x000055555556fec2 <+1394>: mov $0x1,%r12d 0x000055555556fec8 <+1400>: mov %rax,0x10(%rsp) 0x000055555556fecd <+1405>: mov 0x20(%rsp),%rdi 0x000055555556fed2 <+1410>: call 0x55555558b590 0x000055555556fed7 <+1415>: mov 0x10(%rsp),%rdi 0x000055555556fedc <+1420>: call 0x555555588d20 0x000055555556fee1 <+1425>: mov %r14,%rdi 0x000055555556fee4 <+1428>: call 0x55555558a710 0x000055555556fee9 <+1433>: mov %r15,%rdi 0x000055555556feec <+1436>: call *0x26c36(%rip) # 0x555555596b28 0x000055555556fef2 <+1442>: mov 0x8(%rsp),%rdi 0x000055555556fef7 <+1447>: call *0x26633(%rip) # 0x555555596530 0x000055555556fefd <+1453>: mov 0x678(%rsp),%rax 0x000055555556ff05 <+1461>: sub %fs:0x28,%rax 0x000055555556ff0e <+1470>: jne 0x5555555726a4 <main+11604> 0x000055555556ff14 <+1476>: add $0x688,%rsp 0x000055555556ff1b <+1483>: mov %r12d,%eax 0x000055555556ff1e <+1486>: pop %rbx 0x000055555556ff1f <+1487>: pop %rbp 0x000055555556ff20 <+1488>: pop %r12 0x000055555556ff22 <+1490>: pop %r13 0x000055555556ff24 <+1492>: pop %r14 0x000055555556ff26 <+1494>: pop %r15 0x000055555556ff28 <+1496>: ret 0x000055555556ff29 <+1497>: mov 0x180(%rsp),%rax 0x000055555556ff31 <+1505>: cmpb $0x0,0x2a5a8(%rip) # 0x55555559a4e0 0x000055555556ff38 <+1512>: movq $0x0,0x180(%rsp) 0x000055555556ff44 <+1524>: lea 0x188f5(%rip),%rcx # 0x555555588840 0x000055555556ff4b <+1531>: mov 0x2ad96(%rip),%rdx # 0x55555559ace8 0x000055555556ff52 <+1538>: mov 0x2ad87(%rip),%rsi # 0x55555559ace0 0x000055555556ff59 <+1545>: movq $0x0,0xe0(%rsp) 0x000055555556ff65 <+1557>: lea 0x140(%rsp),%r14 0x000055555556ff6d <+1565>: mov %rax,0xd8(%rsp) 0x000055555556ff75 <+1573>: lea 0xc8(%rsp),%rax 0x000055555556ff7d <+1581>: mov %rax,%rbx 0x000055555556ff80 <+1584>: lea 0x510(%rsp),%rax 0x000055555556ff88 <+1592>: mov %rax,0x10(%rsp) 0x000055555556ff8d <+1597>: je 0x55555556fffd <main+1709> 0x000055555556ff8f <+1599>: push %rbx 0x000055555556ff90 <+1600>: mov %r15,%r8 0x000055555556ff93 <+1603>: mov %r14,%rdi 0x000055555556ff96 <+1606>: xor %r9d,%r9d 0x000055555556ff99 <+1609>: push %rcx 0x000055555556ff9a <+1610>: mov %rax,%rcx 0x000055555556ff9d <+1613>: call *0x26795(%rip) # 0x555555596738 0x000055555556ffa3 <+1619>: mov 0x150(%rsp),%rax 0x000055555556ffab <+1627>: mov 0xf0(%rsp),%rbp 0x000055555556ffb3 <+1635>: movq $0x0,0x150(%rsp) 0x000055555556ffbf <+1647>: mov %rax,0xf0(%rsp) 0x000055555556ffc7 <+1655>: pop %rdi 0x000055555556ffc8 <+1656>: pop %r8 0x000055555556ffca <+1658>: test %rbp,%rbp 0x000055555556ffcd <+1661>: je 0x55555556ffe6 <main+1686> 0x000055555556ffcf <+1663>: mov %rbp,%rdi 0x000055555556ffd2 <+1666>: call *0x26260(%rip) # 0x555555596238 0x000055555556ffd8 <+1672>: mov $0x2e8,%esi 0x000055555556ffdd <+1677>: mov %rbp,%rdi 0x000055555556ffe0 <+1680>: call *0x260aa(%rip) # 0x555555596090 0x000055555556ffe6 <+1686>: lea 0x148(%rsp),%rdi 0x000055555556ffee <+1694>: call 0x55555558a1d0 0x000055555556fff3 <+1699>: mov %r14,%rdi 0x000055555556fff6 <+1702>: call 0x55555558a1a0 0x000055555556fffb <+1707>: jmp 0x555555570058 <main+1800> 0x000055555556fffd <+1709>: push %rbx 0x000055555556fffe <+1710>: mov %r15,%r8 0x0000555555570001 <+1713>: mov %r14,%rdi 0x0000555555570004 <+1716>: push %rcx 0x0000555555570005 <+1717>: mov %rax,%rcx 0x0000555555570008 <+1720>: call *0x261aa(%rip) # 0x5555555961b8 0x000055555557000e <+1726>: mov 0x150(%rsp),%rax 0x0000555555570016 <+1734>: mov 0xf0(%rsp),%rbp 0x000055555557001e <+1742>: movq $0x0,0x150(%rsp) 0x000055555557002a <+1754>: mov %rax,0xf0(%rsp) 0x0000555555570032 <+1762>: pop %rcx 0x0000555555570033 <+1763>: pop %rsi 0x0000555555570034 <+1764>: test %rbp,%rbp 0x0000555555570037 <+1767>: je 0x555555570050 <main+1792> 0x0000555555570039 <+1769>: mov %rbp,%rdi 0x000055555557003c <+1772>: call *0x261f6(%rip) # 0x555555596238 0x0000555555570042 <+1778>: mov $0x2e8,%esi 0x0000555555570047 <+1783>: mov %rbp,%rdi 0x000055555557004a <+1786>: call *0x26040(%rip) # 0x555555596090 0x0000555555570050 <+1792>: mov %r14,%rdi 0x0000555555570053 <+1795>: call 0x55555558a1a0 0x0000555555570058 <+1800>: mov 0xe0(%rsp),%rdi 0x0000555555570060 <+1808>: test %rdi,%rdi 0x0000555555570063 <+1811>: je 0x555555571529 <main+7129> 0x0000555555570069 <+1817>: cmpb $0x0,0x2a230(%rip) # 0x55555559a2a0 0x0000555555570070 <+1824>: jne 0x555555570d3d <main+5101> 0x0000555555570076 <+1830>: cmpb $0x0,0x2a163(%rip) # 0x55555559a1e0 0x000055555557007d <+1837>: je 0x5555555700b4 <main+1892> 0x000055555557007f <+1839>: mov 0xe0(%rsp),%rdi 0x0000555555570087 <+1847>: lea 0x48(%rdi),%rax 0x000055555557008b <+1851>: cmp %rax,0x48(%rdi) 0x000055555557008f <+1855>: je 0x5555555700b4 <main+1892> 0x0000555555570091 <+1857>: nopl 0x0(%rax) 0x0000555555570098 <+1864>: mov 0x50(%rdi),%rsi 0x000055555557009c <+1868>: call *0x269be(%rip) # 0x555555596a60 0x00005555555700a2 <+1874>: mov 0xe0(%rsp),%rdi 0x00005555555700aa <+1882>: lea 0x48(%rdi),%rax 0x00005555555700ae <+1886>: cmp %rax,0x48(%rdi) 0x00005555555700b2 <+1890>: jne 0x555555570098 <main+1864> 0x00005555555700b4 <+1892>: mov 0x298ad(%rip),%rdx # 0x555555599968 0x00005555555700bb <+1899>: test %rdx,%rdx 0x00005555555700be <+1902>: jne 0x555555570c32 <main+4834> 0x00005555555700c4 <+1908>: cmpb $0x0,0x2a4d5(%rip) # 0x55555559a5a0 0x00005555555700cb <+1915>: jne 0x5555555700ee <main+1950> 0x00005555555700cd <+1917>: call *0x26305(%rip) # 0x5555555963d8 0x00005555555700d3 <+1923>: xor %edx,%edx 0x00005555555700d5 <+1925>: mov 0xe0(%rsp),%rdi 0x00005555555700dd <+1933>: mov %rax,%rsi 0x00005555555700e0 <+1936>: call *0x26bda(%rip) # 0x555555596cc0 0x00005555555700e6 <+1942>: test %al,%al 0x00005555555700e8 <+1944>: jne 0x55555557155e <main+7182> 0x00005555555700ee <+1950>: xor %esi,%esi 0x00005555555700f0 <+1952>: mov 0xe0(%rsp),%rdi 0x00005555555700f8 <+1960>: call *0x26dea(%rip) # 0x555555596ee8 0x00005555555700fe <+1966>: cmpb $0x0,0x2a89b(%rip) # 0x55555559a9a0 0x0000555555570105 <+1973>: movq $0x0,0xe8(%rsp) 0x0000555555570111 <+1985>: movq $0x0,0xf0(%rsp) 0x000055555557011d <+1997>: je 0x555555570905 <main+4021> 0x0000555555570123 <+2003>: cmpq $0x0,0x2aabd(%rip) # 0x55555559abe8 0x000055555557012b <+2011>: jne 0x555555570b2a <main+4570> 0x0000555555570131 <+2017>: mov 0xe0(%rsp),%rax 0x0000555555570139 <+2025>: mov %r14,%rsi 0x000055555557013c <+2028>: lea 0x230(%rsp),%rbp 0x0000555555570144 <+2036>: movw $0x104,0x150(%rsp) 0x000055555557014e <+2046>: mov %rbp,%rdi 0x0000555555570151 <+2049>: lea 0x190(%rsp),%r12 0x0000555555570159 <+2057>: add $0xf0,%rax 0x000055555557015f <+2063>: mov %rax,0x140(%rsp) 0x0000555555570167 <+2071>: call *0x264fb(%rip) # 0x555555596668 0x000055555557016d <+2077>: lea 0x1a0(%rsp),%rax 0x0000555555570175 <+2085>: movq $0x0,0x198(%rsp) 0x0000555555570181 <+2097>: mov %rax,0x48(%rsp) 0x0000555555570186 <+2102>: mov %rax,0x190(%rsp) 0x000055555557018e <+2110>: lea 0x1c0(%rsp),%rax 0x0000555555570196 <+2118>: mov %rax,0x50(%rsp) 0x000055555557019b <+2123>: mov %rax,0x1b0(%rsp) 0x00005555555701a3 <+2131>: lea 0x420(%rsp),%rax 0x00005555555701ab <+2139>: movb $0x0,0x1a0(%rsp) 0x00005555555701b3 <+2147>: mov %rax,%rdi 0x00005555555701b6 <+2150>: movq $0x0,0x1b8(%rsp) 0x00005555555701c2 <+2162>: movb $0x0,0x1c0(%rsp) 0x00005555555701ca <+2170>: mov %rax,0x40(%rsp) 0x00005555555701cf <+2175>: call *0x26b33(%rip) # 0x555555596d08 0x00005555555701d5 <+2181>: cmpl $0x0,0x250(%rsp) 0x00005555555701dd <+2189>: je 0x555555570a59 <main+4361> 0x00005555555701e3 <+2195>: lea 0x350(%rsp),%rax 0x00005555555701eb <+2203>: mov %rax,%rbx 0x00005555555701ee <+2206>: mov %rax,%rdi 0x00005555555701f1 <+2209>: mov %rax,0x30(%rsp) 0x00005555555701f6 <+2214>: call *0x26744(%rip) # 0x555555596940 0x00005555555701fc <+2220>: mov %r12,%rdi 0x00005555555701ff <+2223>: mov %rbx,%rsi 0x0000555555570202 <+2226>: call 0x5555555861a0 0x0000555555570207 <+2231>: mov 0x350(%rsp),%rdi 0x000055555557020f <+2239>: lea 0x360(%rsp),%rax 0x0000555555570217 <+2247>: mov %rax,0x28(%rsp) 0x000055555557021c <+2252>: cmp %rax,%rdi 0x000055555557021f <+2255>: je 0x555555570233 <main+2275> 0x0000555555570221 <+2257>: mov 0x360(%rsp),%rax 0x0000555555570229 <+2265>: lea 0x1(%rax),%rsi 0x000055555557022d <+2269>: call *0x25e5d(%rip) # 0x555555596090 0x0000555555570233 <+2275>: mov 0x30(%rsp),%rbx 0x0000555555570238 <+2280>: mov %rbx,%rdi 0x000055555557023b <+2283>: call *0x266df(%rip) # 0x555555596920 0x0000555555570241 <+2289>: lea 0x1b0(%rsp),%rdi 0x0000555555570249 <+2297>: mov %rbx,%rsi 0x000055555557024c <+2300>: call 0x5555555861a0 0x0000555555570251 <+2305>: mov 0x350(%rsp),%rdi 0x0000555555570259 <+2313>: cmp 0x28(%rsp),%rdi 0x000055555557025e <+2318>: je 0x555555570272 <main+2338> 0x0000555555570260 <+2320>: mov 0x360(%rsp),%rax 0x0000555555570268 <+2328>: lea 0x1(%rax),%rsi 0x000055555557026c <+2332>: call *0x25e1e(%rip) # 0x555555596090 0x0000555555570272 <+2338>: mov 0x230(%rsp),%r13 0x000055555557027a <+2346>: mov 0x238(%rsp),%r12 0x0000555555570282 <+2354>: lea 0x280(%rsp),%rbx 0x000055555557028a <+2362>: mov %rbx,0x270(%rsp) 0x0000555555570292 <+2370>: mov %r13,%rax 0x0000555555570295 <+2373>: add %r12,%rax 0x0000555555570298 <+2376>: je 0x5555555702a3 <main+2387> 0x000055555557029a <+2378>: test %r13,%r13 0x000055555557029d <+2381>: je 0x5555555726aa <main+11610> 0x00005555555702a3 <+2387>: mov %r12,0x140(%rsp) 0x00005555555702ab <+2395>: cmp $0xf,%r12 0x00005555555702af <+2399>: ja 0x555555570f94 <main+5700> 0x00005555555702b5 <+2405>: cmp $0x1,%r12 0x00005555555702b9 <+2409>: jne 0x555555570f79 <main+5673> 0x00005555555702bf <+2415>: movzbl 0x0(%r13),%eax 0x00005555555702c4 <+2420>: mov %al,0x280(%rsp) 0x00005555555702cb <+2427>: lea 0x270(%rsp),%rax 0x00005555555702d3 <+2435>: mov %rax,0x38(%rsp) 0x00005555555702d8 <+2440>: mov 0x140(%rsp),%rax 0x00005555555702e0 <+2448>: mov 0x270(%rsp),%rdx 0x00005555555702e8 <+2456>: lea 0x1d0(%rsp),%r12 0x00005555555702f0 <+2464>: lea 0x1e0(%rsp),%r13 0x00005555555702f8 <+2472>: mov 0x30(%rsp),%rdi 0x00005555555702fd <+2477>: mov %rax,0x278(%rsp) 0x0000555555570305 <+2485>: movb $0x0,(%rdx,%rax,1) 0x0000555555570309 <+2489>: mov 0x260(%rsp),%rax 0x0000555555570311 <+2497>: movdqa 0x250(%rsp),%xmm1 0x000055555557031a <+2506>: mov %r13,0x1d0(%rsp) 0x0000555555570322 <+2514>: mov %rax,0x2a0(%rsp) 0x000055555557032a <+2522>: movaps %xmm1,0x290(%rsp) 0x0000555555570332 <+2530>: movq $0x0,0x1d8(%rsp) 0x000055555557033e <+2542>: movb $0x0,0x1e0(%rsp) 0x0000555555570346 <+2550>: call *0x2658c(%rip) # 0x5555555968d8 0x000055555557034c <+2556>: mov 0x30(%rsp),%rdi 0x0000555555570351 <+2561>: mov 0x38(%rsp),%rsi 0x0000555555570356 <+2566>: mov %r12,%rdx 0x0000555555570359 <+2569>: call *0x26751(%rip) # 0x555555596ab0 0x000055555557035f <+2575>: mov 0x350(%rsp),%rdi 0x0000555555570367 <+2583>: mov %rax,0x18(%rsp) 0x000055555557036c <+2588>: cmp 0x28(%rsp),%rdi 0x0000555555570371 <+2593>: je 0x555555570385 <main+2613> 0x0000555555570373 <+2595>: mov 0x360(%rsp),%rax 0x000055555557037b <+2603>: lea 0x1(%rax),%rsi 0x000055555557037f <+2607>: call *0x25d0b(%rip) # 0x555555596090 0x0000555555570385 <+2613>: cmpq $0x0,0x18(%rsp) 0x000055555557038b <+2619>: je 0x55555557052e <main+3038> 0x0000555555570391 <+2625>: cmpw $0x0,0x2964f(%rip) # 0x5555555999e8 0x0000555555570399 <+2633>: je 0x555555570d84 <main+5172> 0x000055555557039f <+2639>: mov 0x296ba(%rip),%r12d # 0x555555599a60 0x00005555555703a6 <+2646>: call *0x2685c(%rip) # 0x555555596c08 0x00005555555703ac <+2652>: mov %rax,0x68(%rsp) 0x00005555555703b1 <+2657>: call *0x26b81(%rip) # 0x555555596f38 0x00005555555703b7 <+2663>: lea 0x1f0(%rsp),%rdi 0x00005555555703bf <+2671>: mov %rax,0x60(%rsp) 0x00005555555703c4 <+2676>: call *0x26556(%rip) # 0x555555596920 0x00005555555703ca <+2682>: mov 0x1f0(%rsp),%rcx 0x00005555555703d2 <+2690>: mov 0x1f8(%rsp),%rdx 0x00005555555703da <+2698>: lea 0x210(%rsp),%rdi 0x00005555555703e2 <+2706>: mov %rcx,0x38(%rsp) 0x00005555555703e7 <+2711>: mov %rdx,0x58(%rsp) 0x00005555555703ec <+2716>: call *0x2654e(%rip) # 0x555555596940 0x00005555555703f2 <+2722>: mov 0x218(%rsp),%rcx 0x00005555555703fa <+2730>: mov 0x270(%rsp),%rax 0x0000555555570402 <+2738>: mov 0x210(%rsp),%rdx 0x000055555557040a <+2746>: mov %rcx,0x78(%rsp) 0x000055555557040f <+2751>: mov 0x18(%rsp),%rcx 0x0000555555570414 <+2756>: mov %rax,0x120(%rsp) 0x000055555557041c <+2764>: mov 0x278(%rsp),%rax 0x0000555555570424 <+2772>: mov %rdx,0x80(%rsp) 0x000055555557042c <+2780>: mov %rax,0x128(%rsp) 0x0000555555570434 <+2788>: mov 0x58(%rcx),%rax 0x0000555555570438 <+2792>: test %rax,%rax 0x000055555557043b <+2795>: mov %rax,0x70(%rsp) 0x0000555555570440 <+2800>: je 0x555555571f70 <main+9760> 0x0000555555570446 <+2806>: lea 0x120(%rsp),%rsi 0x000055555557044e <+2814>: mov 0x30(%rsp),%rdi 0x0000555555570453 <+2819>: movw $0x105,0x150(%rsp) 0x000055555557045d <+2829>: mov %rsi,0x140(%rsp) 0x0000555555570465 <+2837>: mov %r14,%rsi 0x0000555555570468 <+2840>: call *0x261fa(%rip) # 0x555555596668 0x000055555557046e <+2846>: push %rdx 0x000055555557046f <+2847>: push $0x0 0x0000555555570471 <+2849>: push %r12 0x0000555555570473 <+2851>: push 0x80(%rsp) 0x000055555557047a <+2858>: push 0x80(%rsp) 0x0000555555570481 <+2865>: push 0x68(%rsp) 0x0000555555570485 <+2869>: mov 0x48(%rsp),%rdi 0x000055555557048a <+2874>: mov 0x68(%rsp),%r8 0x000055555557048f <+2879>: mov 0x88(%rsp),%r9 0x0000555555570497 <+2887>: mov 0xb0(%rsp),%rdx 0x000055555557049f <+2895>: mov 0xa8(%rsp),%rcx 0x00005555555704a7 <+2903>: mov 0x60(%rsp),%rsi 0x00005555555704ac <+2908>: mov 0xa0(%rsp),%rax 0x00005555555704b4 <+2916>: call *%rax 0x00005555555704b6 <+2918>: mov 0x380(%rsp),%rdi 0x00005555555704be <+2926>: mov %rax,0x48(%rsp) 0x00005555555704c3 <+2931>: add $0x30,%rsp 0x00005555555704c7 <+2935>: cmp 0x28(%rsp),%rdi 0x00005555555704cc <+2940>: je 0x5555555704e0 <main+2960> 0x00005555555704ce <+2942>: mov 0x360(%rsp),%rax 0x00005555555704d6 <+2950>: lea 0x1(%rax),%rsi 0x00005555555704da <+2954>: call *0x25bb0(%rip) # 0x555555596090 0x00005555555704e0 <+2960>: mov 0x210(%rsp),%rdi 0x00005555555704e8 <+2968>: lea 0x220(%rsp),%rax 0x00005555555704f0 <+2976>: cmp %rax,%rdi 0x00005555555704f3 <+2979>: je 0x555555570507 <main+2999> 0x00005555555704f5 <+2981>: mov 0x220(%rsp),%rax 0x00005555555704fd <+2989>: lea 0x1(%rax),%rsi 0x0000555555570501 <+2993>: call *0x25b89(%rip) # 0x555555596090 0x0000555555570507 <+2999>: mov 0x1f0(%rsp),%rdi 0x000055555557050f <+3007>: lea 0x200(%rsp),%rax 0x0000555555570517 <+3015>: cmp %rax,%rdi 0x000055555557051a <+3018>: je 0x55555557052e <main+3038> 0x000055555557051c <+3020>: mov 0x200(%rsp),%rax 0x0000555555570524 <+3028>: lea 0x1(%rax),%rsi 0x0000555555570528 <+3032>: call *0x25b62(%rip) # 0x555555596090 0x000055555557052e <+3038>: mov 0x1d0(%rsp),%rdi 0x0000555555570536 <+3046>: cmp %r13,%rdi 0x0000555555570539 <+3049>: je 0x55555557054d <main+3069> 0x000055555557053b <+3051>: mov 0x1e0(%rsp),%rax 0x0000555555570543 <+3059>: lea 0x1(%rax),%rsi 0x0000555555570547 <+3063>: call *0x25b43(%rip) # 0x555555596090 0x000055555557054d <+3069>: mov 0x270(%rsp),%rdi 0x0000555555570555 <+3077>: cmp %rbx,%rdi 0x0000555555570558 <+3080>: je 0x55555557056c <main+3100> 0x000055555557055a <+3082>: mov 0x280(%rsp),%rax 0x0000555555570562 <+3090>: lea 0x1(%rax),%rsi 0x0000555555570566 <+3094>: call *0x25b24(%rip) # 0x555555596090 0x000055555557056c <+3100>: mov 0xe0(%rsp),%r8 0x0000555555570574 <+3108>: mov 0x1b0(%rsp),%rdx 0x000055555557057c <+3116>: mov 0x1b8(%rsp),%rcx 0x0000555555570584 <+3124>: mov 0x190(%rsp),%rdi 0x000055555557058c <+3132>: mov 0x198(%rsp),%rsi 0x0000555555570594 <+3140>: call *0x26606(%rip) # 0x555555596ba0 0x000055555557059a <+3146>: cmpb $0x0,0x2a57f(%rip) # 0x55555559ab20 0x00005555555705a1 <+3153>: jne 0x5555555705b9 <main+3177> 0x00005555555705a3 <+3155>: cmpb $0x0,0x2a3f6(%rip) # 0x55555559a9a0 0x00005555555705aa <+3162>: jne 0x5555555705b9 <main+3177> 0x00005555555705ac <+3164>: cmpb $0x0,0x28f0d(%rip) # 0x5555555994c0 0x00005555555705b3 <+3171>: je 0x5555555715b7 <main+7271> 0x00005555555705b9 <+3177>: cmpb $0x0,0x2a260(%rip) # 0x55555559a820 0x00005555555705c0 <+3184>: jne 0x555555570d48 <main+5112> 0x00005555555705c6 <+3190>: movzbl 0x2a913(%rip),%eax # 0x55555559aee0 0x00005555555705cd <+3197>: mov %eax,%ecx 0x00005555555705cf <+3199>: mov %al,0x60(%rsp) 0x00005555555705d3 <+3203>: movzwl 0x2a78e(%rip),%eax # 0x55555559ad68 0x00005555555705da <+3210>: test %cl,%cl 0x00005555555705dc <+3212>: jne 0x555555570b44 <main+4596> 0x00005555555705e2 <+3218>: test %ax,%ax 0x00005555555705e5 <+3221>: je 0x555555570fdb <main+5771> 0x00005555555705eb <+3227>: mov 0x2a9b6(%rip),%rax # 0x55555559afa8 0x00005555555705f2 <+3234>: cmp %rax,0x2a9a7(%rip) # 0x55555559afa0 0x00005555555705f9 <+3241>: jne 0x555555571501 <main+7089> 0x00005555555705ff <+3247>: lea 0x360(%rsp),%rax 0x0000555555570607 <+3255>: mov %rax,0x28(%rsp) 0x000055555557060c <+3260>: mov %rax,0x350(%rsp) 0x0000555555570614 <+3268>: mov 0x1d635(%rip),%rax # 0x55555558dc50 0x000055555557061b <+3275>: mov %rax,0x358(%rsp) 0x0000555555570623 <+3283>: cmpb $0x0,0x298b6(%rip) # 0x555555599ee0 0x000055555557062a <+3290>: jne 0x555555570db4 <main+5220> 0x0000555555570630 <+3296>: cmpb $0x0,0x297e9(%rip) # 0x555555599e20 0x0000555555570637 <+3303>: jne 0x555555570ea4 <main+5460> 0x000055555557063d <+3309>: cmpb $0x0,0x2971c(%rip) # 0x555555599d60 0x0000555555570644 <+3316>: jne 0x555555570e74 <main+5412> 0x000055555557064a <+3322>: cmpb $0x0,0x294cf(%rip) # 0x555555599b20 0x0000555555570651 <+3329>: jne 0x555555570e44 <main+5364> 0x0000555555570657 <+3335>: cmpb $0x0,0x29642(%rip) # 0x555555599ca0 0x000055555557065e <+3342>: jne 0x555555570e14 <main+5316> 0x0000555555570664 <+3348>: cmpb $0x0,0x29575(%rip) # 0x555555599be0 0x000055555557066b <+3355>: jne 0x555555570de4 <main+5268> 0x0000555555570671 <+3361>: xor %r12d,%r12d 0x0000555555570674 <+3364>: cmpb $0x0,0x2a325(%rip) # 0x55555559a9a0 0x000055555557067b <+3371>: jne 0x55555557069a <main+3402> 0x000055555557067d <+3373>: cmpb $0x0,0x2a25c(%rip) # 0x55555559a8e0 0x0000555555570684 <+3380>: mov $0x1,%r12d 0x000055555557068a <+3386>: jne 0x55555557069a <main+3402> 0x000055555557068c <+3388>: cmpb $0x1,0x2a18d(%rip) # 0x55555559a820 0x0000555555570693 <+3395>: sbb %r12d,%r12d 0x0000555555570696 <+3398>: add $0x3,%r12d 0x000055555557069a <+3402>: xor %ebx,%ebx 0x000055555557069c <+3404>: cmpb $0x0,0x29efd(%rip) # 0x55555559a5a0 0x00005555555706a3 <+3411>: jne 0x5555555706b1 <main+3425> 0x00005555555706a5 <+3413>: cmpb $0x1,0x29d74(%rip) # 0x55555559a420 0x00005555555706ac <+3420>: sbb %ebx,%ebx 0x00005555555706ae <+3422>: add $0x2,%ebx 0x00005555555706b1 <+3425>: movzbl 0x28608(%rip),%eax # 0x555555598cc0 0x00005555555706b8 <+3432>: mov 0x350(%rsp),%rdx 0x00005555555706c0 <+3440>: mov 0x358(%rsp),%ecx 0x00005555555706c7 <+3447>: mov 0x2a712(%rip),%r10 # 0x55555559ade0 0x00005555555706ce <+3454>: mov %eax,0x30(%rsp) 0x00005555555706d2 <+3458>: movzbl 0x28d27(%rip),%eax # 0x555555599400 0x00005555555706d9 <+3465>: mov 0x2a708(%rip),%r11 # 0x55555559ade8 0x00005555555706e0 <+3472>: mov 0xf0(%rsp),%r9 0x00005555555706e8 <+3480>: mov %eax,0x38(%rsp) 0x00005555555706ec <+3484>: movzbl 0x2902d(%rip),%eax # 0x555555599720 0x00005555555706f3 <+3491>: mov 0xe8(%rsp),%r8 0x00005555555706fb <+3499>: mov 0xe0(%rsp),%r13 0x0000555555570703 <+3507>: mov %eax,0x58(%rsp) 0x0000555555570707 <+3511>: movzbl 0x290d2(%rip),%eax # 0x5555555997e0 0x000055555557070e <+3518>: mov %eax,0x60(%rsp) 0x0000555555570712 <+3522>: movzbl 0x288a7(%rip),%eax # 0x555555598fc0 0x0000555555570719 <+3529>: mov %eax,0x68(%rsp) 0x000055555557071d <+3533>: movzbl 0x287dc(%rip),%eax # 0x555555598f00 0x0000555555570724 <+3540>: mov %eax,0x70(%rsp) 0x0000555555570728 <+3544>: mov 0xd8(%rsp),%rax 0x0000555555570730 <+3552>: mov %rax,0x78(%rsp) 0x0000555555570735 <+3557>: mov 0xb0(%rsp),%rax 0x000055555557073d <+3565>: mov (%rax),%rbp 0x0000555555570740 <+3568>: test %rbp,%rbp 0x0000555555570743 <+3571>: je 0x555555570ed4 <main+5508> 0x0000555555570749 <+3577>: mov %rdx,0xa0(%rsp) 0x0000555555570751 <+3585>: mov %rbp,%rdi 0x0000555555570754 <+3588>: mov %rcx,0xa8(%rsp) 0x000055555557075c <+3596>: mov %r10,0x90(%rsp) 0x0000555555570764 <+3604>: mov %r11,0x98(%rsp) 0x000055555557076c <+3612>: mov %r9,0x88(%rsp) 0x0000555555570774 <+3620>: mov %r8,0x80(%rsp) 0x000055555557077c <+3628>: call *0x25ae6(%rip) # 0x555555596268 0x0000555555570782 <+3634>: mov 0x80(%rsp),%r8 0x000055555557078a <+3642>: mov 0x88(%rsp),%r9 0x0000555555570792 <+3650>: mov 0x90(%rsp),%r10 0x000055555557079a <+3658>: mov 0x98(%rsp),%r11 0x00005555555707a2 <+3666>: mov %rax,%rsi 0x00005555555707a5 <+3669>: mov 0xa0(%rsp),%rdx 0x00005555555707ad <+3677>: mov 0xa8(%rsp),%rcx 0x00005555555707b5 <+3685>: push %rax 0x00005555555707b6 <+3686>: mov 0x38(%rsp),%eax 0x00005555555707ba <+3690>: mov %rbp,%rdi 0x00005555555707bd <+3693>: push %rax 0x00005555555707be <+3694>: mov 0x48(%rsp),%eax 0x00005555555707c2 <+3698>: push %rax 0x00005555555707c3 <+3699>: mov 0x70(%rsp),%eax 0x00005555555707c7 <+3703>: push %rax 0x00005555555707c8 <+3704>: mov 0x80(%rsp),%eax 0x00005555555707cf <+3711>: push %rax 0x00005555555707d0 <+3712>: mov 0x90(%rsp),%eax 0x00005555555707d7 <+3719>: push %rax 0x00005555555707d8 <+3720>: mov 0xa0(%rsp),%eax 0x00005555555707df <+3727>: push %rax 0x00005555555707e0 <+3728>: push %rbx 0x00005555555707e1 <+3729>: push %r12 0x00005555555707e3 <+3731>: push %rcx 0x00005555555707e4 <+3732>: push %rdx 0x00005555555707e5 <+3733>: mov %r13,%rdx 0x00005555555707e8 <+3736>: push %r11 0x00005555555707ea <+3738>: push %r10 0x00005555555707ec <+3740>: push 0xe0(%rsp) 0x00005555555707f3 <+3747>: mov 0x88(%rsp),%rcx 0x00005555555707fb <+3755>: addr32 call 0x55555557ad60 <_ZN4llvm15runPassPipelineENS_9StringRefERNS_6ModuleEPNS_13TargetMachineEPNS_14ToolOutputFileES6_S6_S0_NS_8ArrayRefIS0_EENS_8opt_tool10OutputKindENS9_12VerifierKindEbbbbbb> 0x0000555555570801 <+3761>: mov 0x3c0(%rsp),%rdi 0x0000555555570809 <+3769>: xor $0x1,%eax 0x000055555557080c <+3772>: add $0x70,%rsp 0x0000555555570810 <+3776>: movzbl %al,%r12d 0x0000555555570814 <+3780>: lea 0xe8(%rsp),%rbp 0x000055555557081c <+3788>: cmp 0x28(%rsp),%rdi 0x0000555555570821 <+3793>: je 0x555555570829 <main+3801> 0x0000555555570823 <+3795>: call *0x2607f(%rip) # 0x5555555968a8 0x0000555555570829 <+3801>: mov 0x18(%rsp),%rdi 0x000055555557082e <+3806>: test %rdi,%rdi 0x0000555555570831 <+3809>: je 0x555555570839 <main+3817> 0x0000555555570833 <+3811>: mov (%rdi),%rax 0x0000555555570836 <+3814>: call *0x8(%rax) 0x0000555555570839 <+3817>: mov 0x40(%rsp),%rdi 0x000055555557083e <+3822>: call 0x555555588e20 0x0000555555570843 <+3827>: mov 0x1b0(%rsp),%rdi 0x000055555557084b <+3835>: cmp 0x50(%rsp),%rdi 0x0000555555570850 <+3840>: je 0x555555570864 <main+3860> 0x0000555555570852 <+3842>: mov 0x1c0(%rsp),%rax 0x000055555557085a <+3850>: lea 0x1(%rax),%rsi 0x000055555557085e <+3854>: call *0x2582c(%rip) # 0x555555596090 0x0000555555570864 <+3860>: mov 0x190(%rsp),%rdi 0x000055555557086c <+3868>: cmp 0x48(%rsp),%rdi 0x0000555555570871 <+3873>: je 0x555555570885 <main+3893> 0x0000555555570873 <+3875>: mov 0x1a0(%rsp),%rax 0x000055555557087b <+3883>: lea 0x1(%rax),%rsi 0x000055555557087f <+3887>: call *0x2580b(%rip) # 0x555555596090 0x0000555555570885 <+3893>: mov 0x230(%rsp),%rdi 0x000055555557088d <+3901>: lea 0x240(%rsp),%rax 0x0000555555570895 <+3909>: lea 0xf0(%rsp),%r13 0x000055555557089d <+3917>: cmp %rax,%rdi 0x00005555555708a0 <+3920>: je 0x5555555708b4 <main+3940> 0x00005555555708a2 <+3922>: mov 0x240(%rsp),%rax 0x00005555555708aa <+3930>: lea 0x1(%rax),%rsi 0x00005555555708ae <+3934>: call *0x257dc(%rip) # 0x555555596090 0x00005555555708b4 <+3940>: mov %r13,%rdi 0x00005555555708b7 <+3943>: call 0x55555558b540 0x00005555555708bc <+3948>: mov %rbp,%rdi 0x00005555555708bf <+3951>: call 0x55555558b540 0x00005555555708c4 <+3956>: lea 0xe0(%rsp),%rdi 0x00005555555708cc <+3964>: call 0x55555558a1a0 0x00005555555708d1 <+3969>: lea 0xd8(%rsp),%rdi 0x00005555555708d9 <+3977>: call 0x55555558b540 0x00005555555708de <+3982>: jmp 0x55555556fecd <main+1405> 0x00005555555708e3 <+3987>: mov 0x28257(%rip),%edi # 0x555555598b40 0x00005555555708e9 <+3993>: mov %rbp,%rsi 0x00005555555708ec <+3996>: call *0x26666(%rip) # 0x555555596f58 0x00005555555708f2 <+4002>: jmp 0x55555556fca1 <main+849> 0x00005555555708f7 <+4007>: mov %r15,%rdi 0x00005555555708fa <+4010>: call *0x25840(%rip) # 0x555555596140 0x0000555555570900 <+4016>: jmp 0x55555556fd9f <main+1103> 0x0000555555570905 <+4021>: cmpq $0x0,0x2a2db(%rip) # 0x55555559abe8 0x000055555557090d <+4029>: je 0x555555570b12 <main+4546> 0x0000555555570913 <+4035>: movl $0x0,0x140(%rsp) 0x000055555557091e <+4046>: call *0x25bbc(%rip) # 0x5555555964e0 0x0000555555570924 <+4052>: mov 0x2a2b5(%rip),%rbp # 0x55555559abe0 0x000055555557092b <+4059>: mov $0x90,%edi 0x0000555555570930 <+4064>: movzbl 0x29fa9(%rip),%ebx # 0x55555559a8e0 0x0000555555570937 <+4071>: mov 0x2a2aa(%rip),%r13 # 0x55555559abe8 0x000055555557093e <+4078>: mov %rax,0x148(%rsp) 0x0000555555570946 <+4086>: call *0x25f24(%rip) # 0x555555596870 0x000055555557094c <+4092>: mov %rbp,%rsi 0x000055555557094f <+4095>: mov %ebx,%r8d 0x0000555555570952 <+4098>: mov %r14,%rcx 0x0000555555570955 <+4101>: mov %rax,%r12 0x0000555555570958 <+4104>: lea 0xe8(%rsp),%rbp 0x0000555555570960 <+4112>: mov %rax,%rdi 0x0000555555570963 <+4115>: mov %r13,%rdx 0x0000555555570966 <+4118>: call *0x25d9c(%rip) # 0x555555596708 0x000055555557096c <+4124>: mov %r12,%rsi 0x000055555557096f <+4127>: mov %rbp,%rdi 0x0000555555570972 <+4130>: call 0x55555558b4f0 0x0000555555570977 <+4135>: cmpl $0x0,0x140(%rsp) 0x000055555557097f <+4143>: jne 0x555555571618 <main+7368> 0x0000555555570985 <+4149>: mov 0x29cdc(%rip),%r12 # 0x55555559a668 0x000055555557098c <+4156>: test %r12,%r12 0x000055555557098f <+4159>: je 0x555555570131 <main+2017> 0x0000555555570995 <+4165>: mov 0x29cc4(%rip),%r13 # 0x55555559a660 0x000055555557099c <+4172>: mov $0x90,%edi 0x00005555555709a1 <+4177>: call *0x25ec9(%rip) # 0x555555596870 0x00005555555709a7 <+4183>: xor %r8d,%r8d 0x00005555555709aa <+4186>: mov %r14,%rcx 0x00005555555709ad <+4189>: mov %r12,%rdx 0x00005555555709b0 <+4192>: mov %rax,%rbx 0x00005555555709b3 <+4195>: mov %r13,%rsi 0x00005555555709b6 <+4198>: lea 0xf0(%rsp),%r13 0x00005555555709be <+4206>: mov %rax,%rdi 0x00005555555709c1 <+4209>: call *0x25d41(%rip) # 0x555555596708 0x00005555555709c7 <+4215>: mov %rbx,%rsi 0x00005555555709ca <+4218>: mov %r13,%rdi 0x00005555555709cd <+4221>: call 0x55555558b4f0 0x00005555555709d2 <+4226>: cmpl $0x0,0x140(%rsp) 0x00005555555709da <+4234>: je 0x555555570131 <main+2017> 0x00005555555709e0 <+4240>: call *0x259f2(%rip) # 0x5555555963d8 0x00005555555709e6 <+4246>: mov 0x148(%rsp),%rsi 0x00005555555709ee <+4254>: mov 0x140(%rsp),%edx 0x00005555555709f5 <+4261>: lea 0x420(%rsp),%rdi 0x00005555555709fd <+4269>: mov %rax,%r12 0x0000555555570a00 <+4272>: mov (%rsi),%rax 0x0000555555570a03 <+4275>: call *0x20(%rax) 0x0000555555570a06 <+4278>: mov %r12,%rdi 0x0000555555570a09 <+4281>: mov 0x428(%rsp),%rdx 0x0000555555570a11 <+4289>: mov 0x420(%rsp),%rsi 0x0000555555570a19 <+4297>: call *0x260b1(%rip) # 0x555555596ad0 0x0000555555570a1f <+4303>: mov %rax,%rdi 0x0000555555570a22 <+4306>: mov 0x18(%rax),%rax 0x0000555555570a26 <+4310>: cmp %rax,0x10(%rdi) 0x0000555555570a2a <+4314>: jbe 0x555555572612 <main+11458> 0x0000555555570a30 <+4320>: lea 0x1(%rax),%rdx 0x0000555555570a34 <+4324>: mov %rdx,0x18(%rdi) 0x0000555555570a38 <+4328>: movb $0xa,(%rax) 0x0000555555570a3b <+4331>: mov 0x420(%rsp),%rdi 0x0000555555570a43 <+4339>: lea 0x430(%rsp),%rax 0x0000555555570a4b <+4347>: cmp %rax,%rdi 0x0000555555570a4e <+4350>: jne 0x555555571690 <main+7488> 0x0000555555570a54 <+4356>: jmp 0x5555555716a2 <main+7506> 0x0000555555570a59 <+4361>: mov %rbp,%rdi 0x0000555555570a5c <+4364>: call *0x25fae(%rip) # 0x555555596a10 0x0000555555570a62 <+4370>: cmp $0x7,%rdx 0x0000555555570a66 <+4374>: je 0x555555571b68 <main+8728> 0x0000555555570a6c <+4380>: mov %rbp,%rdi 0x0000555555570a6f <+4383>: call *0x25f9b(%rip) # 0x555555596a10 0x0000555555570a75 <+4389>: test %rdx,%rdx 0x0000555555570a78 <+4392>: je 0x555555571b80 <main+8752> 0x0000555555570a7e <+4398>: call *0x25954(%rip) # 0x5555555963d8 0x0000555555570a84 <+4404>: mov %rax,%rdi 0x0000555555570a87 <+4407>: mov 0xb0(%rsp),%rax 0x0000555555570a8f <+4415>: mov (%rax),%rsi 0x0000555555570a92 <+4418>: call 0x555555576a00 0x0000555555570a97 <+4423>: lea 0x1e769(%rip),%rsi # 0x55555558f207 0x0000555555570a9e <+4430>: mov %rax,%rdi 0x0000555555570aa1 <+4433>: call 0x555555576a00 0x0000555555570aa6 <+4438>: mov %rbp,%rdi 0x0000555555570aa9 <+4441>: lea 0xe8(%rsp),%rbp 0x0000555555570ab1 <+4449>: mov %rax,%r12 0x0000555555570ab4 <+4452>: call *0x25f56(%rip) # 0x555555596a10 0x0000555555570aba <+4458>: mov %r12,%rdi 0x0000555555570abd <+4461>: mov $0x1,%r12d 0x0000555555570ac3 <+4467>: mov %rax,%rsi 0x0000555555570ac6 <+4470>: call 0x5555555769a0 0x0000555555570acb <+4475>: lea 0x1e753(%rip),%rsi # 0x55555558f225 0x0000555555570ad2 <+4482>: mov %rax,%rdi 0x0000555555570ad5 <+4485>: call 0x555555576a00 0x0000555555570ada <+4490>: jmp 0x555555570839 <main+3817> 0x0000555555570adf <+4495>: call *0x258f3(%rip) # 0x5555555963d8 0x0000555555570ae5 <+4501>: mov $0x1,%r12d 0x0000555555570aeb <+4507>: mov %rax,%rdi 0x0000555555570aee <+4510>: mov 0xb0(%rsp),%rax 0x0000555555570af6 <+4518>: mov (%rax),%rsi 0x0000555555570af9 <+4521>: call 0x555555576a00 0x0000555555570afe <+4526>: lea 0x1e4a3(%rip),%rsi # 0x55555558efa8 0x0000555555570b05 <+4533>: mov %rax,%rdi 0x0000555555570b08 <+4536>: call 0x555555576a00 0x0000555555570b0d <+4541>: jmp 0x55555556fee9 <main+1433> 0x0000555555570b12 <+4546>: lea 0x1bfd5(%rip),%rsi # 0x55555558caee 0x0000555555570b19 <+4553>: lea 0x2a040(%rip),%rdi # 0x55555559ab60 0x0000555555570b20 <+4560>: call 0x555555587f10 0x0000555555570b25 <+4565>: jmp 0x555555570913 <main+4035> 0x0000555555570b2a <+4570>: call *0x258a8(%rip) # 0x5555555963d8 0x0000555555570b30 <+4576>: lea 0x1e4c9(%rip),%rsi # 0x55555558f000 0x0000555555570b37 <+4583>: mov %rax,%rdi 0x0000555555570b3a <+4586>: call 0x555555576a00 0x0000555555570b3f <+4591>: jmp 0x555555570131 <main+2017> 0x0000555555570b44 <+4596>: mov 0x2a455(%rip),%rbx # 0x55555559afa0 0x0000555555570b4b <+4603>: mov 0x2a456(%rip),%r13 # 0x55555559afa8 0x0000555555570b52 <+4610>: test %ax,%ax 0x0000555555570b55 <+4613>: jne 0x5555555705eb <main+3227> 0x0000555555570b5b <+4619>: lea 0x360(%rsp),%rax 0x0000555555570b63 <+4627>: lea 0x350(%rsp),%rdi 0x0000555555570b6b <+4635>: mov %rax,0x28(%rsp) 0x0000555555570b70 <+4640>: mov %rax,0x350(%rsp) 0x0000555555570b78 <+4648>: mov 0x1d0d1(%rip),%rax # 0x55555558dc50 0x0000555555570b7f <+4655>: mov %rax,0x358(%rsp) 0x0000555555570b87 <+4663>: xor %eax,%eax 0x0000555555570b89 <+4665>: cmp %r13,%rbx 0x0000555555570b8c <+4668>: jne 0x555555570bc9 <main+4729> 0x0000555555570b8e <+4670>: jmp 0x555555570623 <main+3283> 0x0000555555570b93 <+4675>: nopl 0x0(%rax,%rax,1) 0x0000555555570b98 <+4680>: shl $0x4,%rax 0x0000555555570b9c <+4684>: add 0x350(%rsp),%rax 0x0000555555570ba4 <+4692>: add $0x8,%rbx 0x0000555555570ba8 <+4696>: mov %r12,(%rax) 0x0000555555570bab <+4699>: mov %rbp,0x8(%rax) 0x0000555555570baf <+4703>: mov 0x358(%rsp),%eax 0x0000555555570bb6 <+4710>: add $0x1,%eax 0x0000555555570bb9 <+4713>: mov %eax,0x358(%rsp) 0x0000555555570bc0 <+4720>: cmp %rbx,%r13 0x0000555555570bc3 <+4723>: je 0x555555570623 <main+3283> 0x0000555555570bc9 <+4729>: mov (%rbx),%rdx 0x0000555555570bcc <+4732>: mov 0x18(%rdx),%rbp 0x0000555555570bd0 <+4736>: mov 0x10(%rdx),%r12 0x0000555555570bd4 <+4740>: cmp %eax,0x35c(%rsp) 0x0000555555570bdb <+4747>: ja 0x555555570b98 <main+4680> 0x0000555555570bdd <+4749>: mov %rdi,0x30(%rsp) 0x0000555555570be2 <+4754>: xor %edx,%edx 0x0000555555570be4 <+4756>: mov 0x28(%rsp),%rsi 0x0000555555570be9 <+4761>: add $0x8,%rbx 0x0000555555570bed <+4765>: mov $0x10,%ecx 0x0000555555570bf2 <+4770>: call *0x25608(%rip) # 0x555555596200 0x0000555555570bf8 <+4776>: mov 0x358(%rsp),%eax 0x0000555555570bff <+4783>: mov 0x30(%rsp),%rdi 0x0000555555570c04 <+4788>: shl $0x4,%rax 0x0000555555570c08 <+4792>: add 0x350(%rsp),%rax 0x0000555555570c10 <+4800>: mov %r12,(%rax) 0x0000555555570c13 <+4803>: mov %rbp,0x8(%rax) 0x0000555555570c17 <+4807>: mov 0x358(%rsp),%eax 0x0000555555570c1e <+4814>: add $0x1,%eax 0x0000555555570c21 <+4817>: cmp %rbx,%r13 0x0000555555570c24 <+4820>: mov %eax,0x358(%rsp) 0x0000555555570c2b <+4827>: jne 0x555555570bc9 <main+4729> 0x0000555555570c2d <+4829>: jmp 0x555555570623 <main+3283> 0x0000555555570c32 <+4834>: mov 0xe0(%rsp),%rbx 0x0000555555570c3a <+4842>: mov 0x28d1f(%rip),%rsi # 0x555555599960 0x0000555555570c41 <+4849>: lea 0x350(%rsp),%rdi 0x0000555555570c49 <+4857>: call *0x25d51(%rip) # 0x5555555969a0 0x0000555555570c4f <+4863>: mov 0x350(%rsp),%r12 0x0000555555570c57 <+4871>: test %r12,%r12 0x0000555555570c5a <+4874>: je 0x555555570edb <main+5515> 0x0000555555570c60 <+4880>: mov 0x358(%rsp),%r13 0x0000555555570c68 <+4888>: lea 0x430(%rsp),%rbp 0x0000555555570c70 <+4896>: lea 0x420(%rsp),%rdi 0x0000555555570c78 <+4904>: mov %rbp,0x420(%rsp) 0x0000555555570c80 <+4912>: mov %r13,0x140(%rsp) 0x0000555555570c88 <+4920>: cmp $0xf,%r13 0x0000555555570c8c <+4924>: ja 0x555555571f45 <main+9717> 0x0000555555570c92 <+4930>: cmp $0x1,%r13 0x0000555555570c96 <+4934>: jne 0x5555555716ad <main+7517> 0x0000555555570c9c <+4940>: movzbl (%r12),%eax 0x0000555555570ca1 <+4945>: mov %al,0x430(%rsp) 0x0000555555570ca8 <+4952>: mov 0x140(%rsp),%rax 0x0000555555570cb0 <+4960>: mov 0x420(%rsp),%rdx 0x0000555555570cb8 <+4968>: lea 0x100(%rbx),%rcx 0x0000555555570cbf <+4975>: mov %rax,0x428(%rsp) 0x0000555555570cc7 <+4983>: movb $0x0,(%rdx,%rax,1) 0x0000555555570ccb <+4987>: mov 0x420(%rsp),%rdx 0x0000555555570cd3 <+4995>: mov 0xf0(%rbx),%rdi 0x0000555555570cda <+5002>: cmp %rbp,%rdx 0x0000555555570cdd <+5005>: je 0x555555571f7e <main+9774> 0x0000555555570ce3 <+5011>: mov 0x428(%rsp),%rax 0x0000555555570ceb <+5019>: mov 0x430(%rsp),%rsi 0x0000555555570cf3 <+5027>: cmp %rcx,%rdi 0x0000555555570cf6 <+5030>: je 0x555555571e96 <main+9542> 0x0000555555570cfc <+5036>: movq %rax,%xmm0 0x0000555555570d01 <+5041>: movq %rsi,%xmm2 0x0000555555570d06 <+5046>: mov 0x100(%rbx),%rcx 0x0000555555570d0d <+5053>: mov %rdx,0xf0(%rbx) 0x0000555555570d14 <+5060>: punpcklqdq %xmm2,%xmm0 0x0000555555570d18 <+5064>: movups %xmm0,0xf8(%rbx) 0x0000555555570d1f <+5071>: test %rdi,%rdi 0x0000555555570d22 <+5074>: je 0x555555571eb2 <main+9570> 0x0000555555570d28 <+5080>: mov %rdi,0x420(%rsp) 0x0000555555570d30 <+5088>: mov %rcx,0x430(%rsp) 0x0000555555570d38 <+5096>: jmp 0x555555570f13 <main+5571> 0x0000555555570d3d <+5101>: call *0x2583d(%rip) # 0x555555596580 0x0000555555570d43 <+5107>: jmp 0x555555570076 <main+1830> 0x0000555555570d48 <+5112>: movzbl 0x29a10(%rip),%r8d # 0x55555559a760 0x0000555555570d50 <+5120>: mov $0x12,%ecx 0x0000555555570d55 <+5125>: mov $0x1,%esi 0x0000555555570d5a <+5130>: mov 0xe0(%rsp),%rdi 0x0000555555570d62 <+5138>: lea 0x1e4c9(%rip),%rdx # 0x55555558f232 0x0000555555570d69 <+5145>: call *0x258d9(%rip) # 0x555555596648 0x0000555555570d6f <+5151>: jmp 0x5555555705c6 <main+3190> 0x0000555555570d74 <+5156>: mov $0xa,%esi 0x0000555555570d79 <+5161>: call *0x25629(%rip) # 0x5555555963a8 0x0000555555570d7f <+5167>: jmp 0x55555556fe80 <main+1328> 0x0000555555570d84 <+5172>: cmpb $0x0,0x29095(%rip) # 0x555555599e20 0x0000555555570d8b <+5179>: jne 0x555555571ebf <main+9583> 0x0000555555570d91 <+5185>: cmpb $0x0,0x28fc8(%rip) # 0x555555599d60 0x0000555555570d98 <+5192>: jne 0x5555555716da <main+7562> 0x0000555555570d9e <+5198>: cmpb $0x1,0x28d7b(%rip) # 0x555555599b20 0x0000555555570da5 <+5205>: sbb %r12d,%r12d 0x0000555555570da8 <+5208>: not %r12d 0x0000555555570dab <+5211>: and $0x3,%r12d 0x0000555555570daf <+5215>: jmp 0x5555555703a6 <main+2646> 0x0000555555570db4 <+5220>: lea 0x1e48a(%rip),%rax # 0x55555558f245 0x0000555555570dbb <+5227>: mov %r14,%rsi 0x0000555555570dbe <+5230>: lea 0x350(%rsp),%rdi 0x0000555555570dc6 <+5238>: movq $0xb,0x148(%rsp) 0x0000555555570dd2 <+5250>: mov %rax,0x140(%rsp) 0x0000555555570dda <+5258>: call 0x555555588f80 0x0000555555570ddf <+5263>: jmp 0x555555570630 <main+3296> 0x0000555555570de4 <+5268>: lea 0x1e496(%rip),%rax # 0x55555558f281 0x0000555555570deb <+5275>: mov %r14,%rsi 0x0000555555570dee <+5278>: lea 0x350(%rsp),%rdi 0x0000555555570df6 <+5286>: movq $0xb,0x148(%rsp) 0x0000555555570e02 <+5298>: mov %rax,0x140(%rsp) 0x0000555555570e0a <+5306>: call 0x555555588f80 0x0000555555570e0f <+5311>: jmp 0x555555570671 <main+3361> 0x0000555555570e14 <+5316>: lea 0x1e45a(%rip),%rax # 0x55555558f275 0x0000555555570e1b <+5323>: mov %r14,%rsi 0x0000555555570e1e <+5326>: lea 0x350(%rsp),%rdi 0x0000555555570e26 <+5334>: movq $0xb,0x148(%rsp) 0x0000555555570e32 <+5346>: mov %rax,0x140(%rsp) 0x0000555555570e3a <+5354>: call 0x555555588f80 0x0000555555570e3f <+5359>: jmp 0x555555570664 <main+3348> 0x0000555555570e44 <+5364>: lea 0x1e41e(%rip),%rax # 0x55555558f269 0x0000555555570e4b <+5371>: mov %r14,%rsi 0x0000555555570e4e <+5374>: lea 0x350(%rsp),%rdi 0x0000555555570e56 <+5382>: movq $0xb,0x148(%rsp) 0x0000555555570e62 <+5394>: mov %rax,0x140(%rsp) 0x0000555555570e6a <+5402>: call 0x555555588f80 0x0000555555570e6f <+5407>: jmp 0x555555570657 <main+3335> 0x0000555555570e74 <+5412>: lea 0x1e3e2(%rip),%rax # 0x55555558f25d 0x0000555555570e7b <+5419>: mov %r14,%rsi 0x0000555555570e7e <+5422>: lea 0x350(%rsp),%rdi 0x0000555555570e86 <+5430>: movq $0xb,0x148(%rsp) 0x0000555555570e92 <+5442>: mov %rax,0x140(%rsp) 0x0000555555570e9a <+5450>: call 0x555555588f80 0x0000555555570e9f <+5455>: jmp 0x55555557064a <main+3322> 0x0000555555570ea4 <+5460>: lea 0x1e3a6(%rip),%rax # 0x55555558f251 0x0000555555570eab <+5467>: mov %r14,%rsi 0x0000555555570eae <+5470>: lea 0x350(%rsp),%rdi 0x0000555555570eb6 <+5478>: movq $0xb,0x148(%rsp) 0x0000555555570ec2 <+5490>: mov %rax,0x140(%rsp) 0x0000555555570eca <+5498>: call 0x555555588f80 0x0000555555570ecf <+5503>: jmp 0x55555557063d <main+3309> 0x0000555555570ed4 <+5508>: xor %esi,%esi 0x0000555555570ed6 <+5510>: jmp 0x5555555707b5 <main+3685> 0x0000555555570edb <+5515>: lea 0x430(%rsp),%rbp 0x0000555555570ee3 <+5523>: movb $0x0,0x430(%rsp) 0x0000555555570eeb <+5531>: xor %edx,%edx 0x0000555555570eed <+5533>: movq $0x0,0x428(%rsp) 0x0000555555570ef9 <+5545>: mov %rbp,0x420(%rsp) 0x0000555555570f01 <+5553>: mov 0xf0(%rbx),%rdi 0x0000555555570f08 <+5560>: mov %rdx,0xf8(%rbx) 0x0000555555570f0f <+5567>: movb $0x0,(%rdi,%rdx,1) 0x0000555555570f13 <+5571>: mov 0x420(%rsp),%rax 0x0000555555570f1b <+5579>: movq $0x0,0x428(%rsp) 0x0000555555570f27 <+5591>: movb $0x0,(%rax) 0x0000555555570f2a <+5594>: mov 0x420(%rsp),%rdi 0x0000555555570f32 <+5602>: cmp %rbp,%rdi 0x0000555555570f35 <+5605>: je 0x555555570f49 <main+5625> 0x0000555555570f37 <+5607>: mov 0x430(%rsp),%rax 0x0000555555570f3f <+5615>: lea 0x1(%rax),%rsi 0x0000555555570f43 <+5619>: call *0x25147(%rip) # 0x555555596090 0x0000555555570f49 <+5625>: mov 0x350(%rsp),%rdi 0x0000555555570f51 <+5633>: lea 0x360(%rsp),%rax 0x0000555555570f59 <+5641>: cmp %rax,%rdi 0x0000555555570f5c <+5644>: je 0x5555555700c4 <main+1908> 0x0000555555570f62 <+5650>: mov 0x360(%rsp),%rax 0x0000555555570f6a <+5658>: lea 0x1(%rax),%rsi 0x0000555555570f6e <+5662>: call *0x2511c(%rip) # 0x555555596090 0x0000555555570f74 <+5668>: jmp 0x5555555700c4 <main+1908> 0x0000555555570f79 <+5673>: lea 0x270(%rsp),%rax 0x0000555555570f81 <+5681>: mov %rax,0x38(%rsp) 0x0000555555570f86 <+5686>: test %r12,%r12 0x0000555555570f89 <+5689>: je 0x5555555702d8 <main+2440> 0x0000555555570f8f <+5695>: mov %rbx,%rdi 0x0000555555570f92 <+5698>: jmp 0x555555570fca <main+5754> 0x0000555555570f94 <+5700>: lea 0x270(%rsp),%rax 0x0000555555570f9c <+5708>: xor %edx,%edx 0x0000555555570f9e <+5710>: mov %r14,%rsi 0x0000555555570fa1 <+5713>: mov %rax,%rdi 0x0000555555570fa4 <+5716>: mov %rax,0x38(%rsp) 0x0000555555570fa9 <+5721>: call *0x254b1(%rip) # 0x555555596460 0x0000555555570faf <+5727>: mov %rax,0x270(%rsp) 0x0000555555570fb7 <+5735>: mov %rax,%rdi 0x0000555555570fba <+5738>: mov 0x140(%rsp),%rax 0x0000555555570fc2 <+5746>: mov %rax,0x280(%rsp) 0x0000555555570fca <+5754>: mov %r12,%rdx 0x0000555555570fcd <+5757>: mov %r13,%rsi 0x0000555555570fd0 <+5760>: call *0x2584a(%rip) # 0x555555596820 0x0000555555570fd6 <+5766>: jmp 0x5555555702d8 <main+2440> 0x0000555555570fdb <+5771>: mov %r14,%rdi 0x0000555555570fde <+5774>: call *0x257d4(%rip) # 0x5555555967b8 0x0000555555570fe4 <+5780>: lea 0x24ddd(%rip),%rax # 0x555555595dc8 <_ZTV20OptCustomPassManager> 0x0000555555570feb <+5787>: pxor %xmm0,%xmm0 0x0000555555570fef <+5791>: movl $0x0,0x160(%rsp) 0x0000555555570ffa <+5802>: movq $0x0,0x150(%rsp) 0x0000555555571006 <+5814>: add $0x10,%rax 0x000055555557100a <+5818>: movups %xmm0,0x168(%rsp) 0x0000555555571012 <+5826>: mov %rax,0x140(%rsp) 0x000055555557101a <+5834>: movzbl 0x283df(%rip),%eax # 0x555555599400 0x0000555555571021 <+5841>: movq $0x0,0x158(%rsp) 0x000055555557102d <+5853>: movq $0x0,0x178(%rsp) 0x0000555555571039 <+5865>: mov %al,0x70(%rsp) 0x000055555557103d <+5869>: test %al,%al 0x000055555557103f <+5871>: je 0x55555557104f <main+5887> 0x0000555555571041 <+5873>: movzbl 0x282f8(%rip),%eax # 0x555555599340 0x0000555555571048 <+5880>: xor $0x1,%eax 0x000055555557104b <+5883>: mov %al,0x70(%rsp) 0x000055555557104f <+5887>: lea 0x350(%rsp),%rax 0x0000555555571057 <+5895>: mov %rbp,%rsi 0x000055555557105a <+5898>: mov %rax,0x30(%rsp) 0x000055555557105f <+5903>: mov %rax,%rdi 0x0000555555571062 <+5906>: call *0x25688(%rip) # 0x5555555966f0 0x0000555555571068 <+5912>: cmpb $0x0,0x285f1(%rip) # 0x555555599660 0x000055555557106f <+5919>: jne 0x5555555716ca <main+7546> 0x0000555555571075 <+5925>: mov 0x28504(%rip),%r13 # 0x555555599580 0x000055555557107c <+5932>: mov 0x30(%rsp),%rbp 0x0000555555571081 <+5937>: mov %r14,0x28(%rsp) 0x0000555555571086 <+5942>: lea 0x120(%rsp),%r12 0x000055555557108e <+5950>: mov 0x284f3(%rip),%rbx # 0x555555599588 0x0000555555571095 <+5957>: mov %r13,%r14 0x0000555555571098 <+5960>: jmp 0x5555555710da <main+6026> 0x000055555557109a <+5962>: mov (%r14),%rsi 0x000055555557109d <+5965>: mov 0x8(%r14),%rdx 0x00005555555710a1 <+5969>: mov %r12,%rcx 0x00005555555710a4 <+5972>: mov %rbp,%rdi 0x00005555555710a7 <+5975>: call *0x25ed3(%rip) # 0x555555596f80 0x00005555555710ad <+5981>: add $0x20,%r14 0x00005555555710b1 <+5985>: test %al,%al 0x00005555555710b3 <+5987>: je 0x555555572015 <main+9925> 0x00005555555710b9 <+5993>: mov 0x120(%rsp),%ecx 0x00005555555710c0 <+6000>: mov $0x3,%eax 0x00005555555710c5 <+6005>: mov %ecx,%edx 0x00005555555710c7 <+6007>: and $0x3,%ecx 0x00005555555710ca <+6010>: add %ecx,%ecx 0x00005555555710cc <+6012>: shr $0x2,%edx 0x00005555555710cf <+6015>: shl %cl,%eax 0x00005555555710d1 <+6017>: not %eax 0x00005555555710d3 <+6019>: and %al,0x350(%rsp,%rdx,1) 0x00005555555710da <+6026>: mov %r14,%r13 0x00005555555710dd <+6029>: cmp %r14,%rbx 0x00005555555710e0 <+6032>: jne 0x55555557109a <main+5962> 0x00005555555710e2 <+6034>: mov 0x28(%rsp),%r14 0x00005555555710e7 <+6039>: mov $0x118,%edi 0x00005555555710ec <+6044>: call *0x2577e(%rip) # 0x555555596870 0x00005555555710f2 <+6050>: mov 0x30(%rsp),%rsi 0x00005555555710f7 <+6055>: mov %rax,%rbp 0x00005555555710fa <+6058>: mov %rax,%rdi 0x00005555555710fd <+6061>: call *0x25bd5(%rip) # 0x555555596cd8 0x0000555555571103 <+6067>: mov %rbp,%rsi 0x0000555555571106 <+6070>: mov %r14,%rdi 0x0000555555571109 <+6073>: call 0x55555558b600 0x000055555557110e <+6078>: mov 0x18(%rsp),%rsi 0x0000555555571113 <+6083>: lea 0x270(%rsp),%rax 0x000055555557111b <+6091>: mov %rax,0x38(%rsp) 0x0000555555571120 <+6096>: mov %rax,%rdi 0x0000555555571123 <+6099>: test %rsi,%rsi 0x0000555555571126 <+6102>: je 0x5555555722e9 <main+10649> 0x000055555557112c <+6108>: call *0x2565e(%rip) # 0x555555596790 0x0000555555571132 <+6114>: mov 0x38(%rsp),%rbx 0x0000555555571137 <+6119>: mov %rbx,%rdi 0x000055555557113a <+6122>: call *0x24ed0(%rip) # 0x555555596010 0x0000555555571140 <+6128>: mov %r14,%rdi 0x0000555555571143 <+6131>: mov %rax,%rsi 0x0000555555571146 <+6134>: call 0x55555558b600 0x000055555557114b <+6139>: mov 0x280(%rsp),%rax 0x0000555555571153 <+6147>: test %rax,%rax 0x0000555555571156 <+6150>: je 0x555555571165 <main+6165> 0x0000555555571158 <+6152>: mov $0x3,%edx 0x000055555557115d <+6157>: mov %rbx,%rsi 0x0000555555571160 <+6160>: mov %rbx,%rdi 0x0000555555571163 <+6163>: call *%rax 0x0000555555571165 <+6165>: cmpb $0x0,0x70(%rsp) 0x000055555557116a <+6170>: jne 0x5555555721c0 <main+10352> 0x0000555555571170 <+6176>: cmpb $0x0,0x28d69(%rip) # 0x555555599ee0 0x0000555555571177 <+6183>: jne 0x5555555711a9 <main+6233> 0x0000555555571179 <+6185>: cmpb $0x0,0x28ca0(%rip) # 0x555555599e20 0x0000555555571180 <+6192>: jne 0x5555555711a9 <main+6233> 0x0000555555571182 <+6194>: cmpb $0x0,0x28bd7(%rip) # 0x555555599d60 0x0000555555571189 <+6201>: jne 0x5555555711a9 <main+6233> 0x000055555557118b <+6203>: cmpb $0x0,0x28b0e(%rip) # 0x555555599ca0 0x0000555555571192 <+6210>: jne 0x5555555711a9 <main+6233> 0x0000555555571194 <+6212>: cmpb $0x0,0x28a45(%rip) # 0x555555599be0 0x000055555557119b <+6219>: jne 0x5555555711a9 <main+6233> 0x000055555557119d <+6221>: xor %r13d,%r13d 0x00005555555711a0 <+6224>: cmpb $0x0,0x28979(%rip) # 0x555555599b20 0x00005555555711a7 <+6231>: je 0x555555571218 <main+6344> 0x00005555555711a9 <+6233>: mov 0xe0(%rsp),%rbp 0x00005555555711b1 <+6241>: mov $0x18,%edi 0x00005555555711b6 <+6246>: call *0x256b4(%rip) # 0x555555596870 0x00005555555711bc <+6252>: mov %rax,%rdi 0x00005555555711bf <+6255>: mov %rbp,%rsi 0x00005555555711c2 <+6258>: mov %rax,%r13 0x00005555555711c5 <+6261>: call *0x2584d(%rip) # 0x555555596a18 0x00005555555711cb <+6267>: mov 0x18(%rsp),%rsi 0x00005555555711d0 <+6272>: mov 0x38(%rsp),%rdi 0x00005555555711d5 <+6277>: test %rsi,%rsi 0x00005555555711d8 <+6280>: je 0x5555555722f4 <main+10660> 0x00005555555711de <+6286>: call *0x255ac(%rip) # 0x555555596790 0x00005555555711e4 <+6292>: mov 0x38(%rsp),%rbx 0x00005555555711e9 <+6297>: mov %rbx,%rdi 0x00005555555711ec <+6300>: call *0x24e1e(%rip) # 0x555555596010 0x00005555555711f2 <+6306>: mov %r13,%rdi 0x00005555555711f5 <+6309>: mov %rax,%rsi 0x00005555555711f8 <+6312>: call *0x257e2(%rip) # 0x5555555969e0 0x00005555555711fe <+6318>: mov 0x280(%rsp),%rax 0x0000555555571206 <+6326>: test %rax,%rax 0x0000555555571209 <+6329>: je 0x555555571218 <main+6344> 0x000055555557120b <+6331>: mov $0x3,%edx 0x0000555555571210 <+6336>: mov %rbx,%rsi 0x0000555555571213 <+6339>: mov %rbx,%rdi 0x0000555555571216 <+6342>: call *%rax 0x0000555555571218 <+6344>: cmpb $0x0,0x27f61(%rip) # 0x555555599180 0x000055555557121f <+6351>: je 0x555555571282 <main+6450> 0x0000555555571221 <+6353>: cmpq $0x0,0xe8(%rsp) 0x000055555557122a <+6362>: je 0x55555557237a <main+10794> 0x0000555555571230 <+6368>: mov 0xe8(%rsp),%rax 0x0000555555571238 <+6376>: mov 0x88(%rax),%rdi 0x000055555557123f <+6383>: addr32 call 0x5555555733e0 <_ZN4llvm23createBreakpointPrinterERNS_11raw_ostreamE> 0x0000555555571245 <+6389>: mov %r14,%rdi 0x0000555555571248 <+6392>: mov %rax,%rsi 0x000055555557124b <+6395>: call 0x55555558b600 0x0000555555571250 <+6400>: cmpq $0x0,0x29778(%rip) # 0x55555559a9d0 0x0000555555571258 <+6408>: movb $0x1,0xca(%rsp) 0x0000555555571260 <+6416>: movb $0x1,0x29739(%rip) # 0x55555559a9a0 0x0000555555571267 <+6423>: je 0x55555557268e <main+11582> 0x000055555557126d <+6429>: lea 0xca(%rsp),%rsi 0x0000555555571275 <+6437>: lea 0x29744(%rip),%rdi # 0x55555559a9c0 0x000055555557127c <+6444>: call *0x29756(%rip) # 0x55555559a9d8 0x0000555555571282 <+6450>: mov 0x18(%rsp),%rdi 0x0000555555571287 <+6455>: test %rdi,%rdi 0x000055555557128a <+6458>: je 0x5555555712a0 <main+6480> 0x000055555557128c <+6460>: mov (%rdi),%rax 0x000055555557128f <+6463>: mov %r14,%rsi 0x0000555555571292 <+6466>: call *0x70(%rax) 0x0000555555571295 <+6469>: mov %r14,%rdi 0x0000555555571298 <+6472>: mov %rax,%rsi 0x000055555557129b <+6475>: call 0x55555558b600 0x00005555555712a0 <+6480>: lea 0xcb(%rsp),%rax 0x00005555555712a8 <+6488>: xor %ebx,%ebx 0x00005555555712aa <+6490>: xor %ebp,%ebp 0x00005555555712ac <+6492>: mov %rax,0x68(%rsp) 0x00005555555712b1 <+6497>: mov 0x29ce8(%rip),%rax # 0x55555559afa0 0x00005555555712b8 <+6504>: cmp %rax,0x29ce9(%rip) # 0x55555559afa8 0x00005555555712bf <+6511>: je 0x555555571b93 <main+8771> 0x00005555555712c5 <+6517>: mov %r15,0x78(%rsp) 0x00005555555712ca <+6522>: mov 0x18(%rsp),%r15 0x00005555555712cf <+6527>: jmp 0x5555555712f9 <main+6569> 0x00005555555712d1 <+6529>: nopl 0x0(%rax) 0x00005555555712d8 <+6536>: mov 0x29cc9(%rip),%rax # 0x55555559afa8 0x00005555555712df <+6543>: sub 0x29cba(%rip),%rax # 0x55555559afa0 0x00005555555712e6 <+6550>: lea 0x1(%rbx),%ebp 0x00005555555712e9 <+6553>: sar $0x3,%rax 0x00005555555712ed <+6557>: mov %rbp,%rbx 0x00005555555712f0 <+6560>: cmp %rax,%rbp 0x00005555555712f3 <+6563>: jae 0x555555571b8e <main+8766> 0x00005555555712f9 <+6569>: cmpb $0x0,0x28ca0(%rip) # 0x555555599fa0 0x0000555555571300 <+6576>: je 0x555555571319 <main+6601> 0x0000555555571302 <+6578>: mov 0x29caf(%rip),%rdx # 0x55555559afb8 0x0000555555571309 <+6585>: movzwl 0x28c1c(%rip),%eax # 0x555555599f2c 0x0000555555571310 <+6592>: cmp %eax,(%rdx,%rbp,4) 0x0000555555571313 <+6595>: ja 0x555555571755 <main+7685> 0x0000555555571319 <+6601>: cmpb $0x0,0x28bc0(%rip) # 0x555555599ee0 0x0000555555571320 <+6608>: je 0x555555571339 <main+6633> 0x0000555555571322 <+6610>: mov 0x29c8f(%rip),%rdx # 0x55555559afb8 0x0000555555571329 <+6617>: movzwl 0x28b3c(%rip),%eax # 0x555555599e6c 0x0000555555571330 <+6624>: cmp %eax,(%rdx,%rbp,4) 0x0000555555571333 <+6627>: ja 0x555555571791 <main+7745> 0x0000555555571339 <+6633>: cmpb $0x0,0x28ae0(%rip) # 0x555555599e20 0x0000555555571340 <+6640>: je 0x555555571359 <main+6665> 0x0000555555571342 <+6642>: mov 0x29c6f(%rip),%rdx # 0x55555559afb8 0x0000555555571349 <+6649>: movzwl 0x28a5c(%rip),%eax # 0x555555599dac 0x0000555555571350 <+6656>: cmp %eax,(%rdx,%rbp,4) 0x0000555555571353 <+6659>: ja 0x5555555717db <main+7819> 0x0000555555571359 <+6665>: cmpb $0x0,0x28a00(%rip) # 0x555555599d60 0x0000555555571360 <+6672>: je 0x555555571379 <main+6697> 0x0000555555571362 <+6674>: mov 0x29c4f(%rip),%rdx # 0x55555559afb8 0x0000555555571369 <+6681>: movzwl 0x2897c(%rip),%eax # 0x555555599cec 0x0000555555571370 <+6688>: cmp %eax,(%rdx,%rbp,4) 0x0000555555571373 <+6691>: ja 0x555555571828 <main+7896> 0x0000555555571379 <+6697>: cmpb $0x0,0x28920(%rip) # 0x555555599ca0 0x0000555555571380 <+6704>: je 0x555555571399 <main+6729> 0x0000555555571382 <+6706>: mov 0x29c2f(%rip),%rdx # 0x55555559afb8 0x0000555555571389 <+6713>: movzwl 0x2889c(%rip),%eax # 0x555555599c2c 0x0000555555571390 <+6720>: cmp %eax,(%rdx,%rbp,4) 0x0000555555571393 <+6723>: ja 0x555555571875 <main+7973> 0x0000555555571399 <+6729>: cmpb $0x0,0x28840(%rip) # 0x555555599be0 0x00005555555713a0 <+6736>: je 0x5555555713b9 <main+6761> 0x00005555555713a2 <+6738>: mov 0x29c0f(%rip),%rdx # 0x55555559afb8 0x00005555555713a9 <+6745>: movzwl 0x287bc(%rip),%eax # 0x555555599b6c 0x00005555555713b0 <+6752>: cmp %eax,(%rdx,%rbp,4) 0x00005555555713b3 <+6755>: ja 0x5555555718c5 <main+8053> 0x00005555555713b9 <+6761>: cmpb $0x0,0x28760(%rip) # 0x555555599b20 0x00005555555713c0 <+6768>: je 0x5555555713d9 <main+6793> 0x00005555555713c2 <+6770>: mov 0x29bef(%rip),%rdx # 0x55555559afb8 0x00005555555713c9 <+6777>: movzwl 0x286dc(%rip),%eax # 0x555555599aac 0x00005555555713d0 <+6784>: cmp %eax,(%rdx,%rbp,4) 0x00005555555713d3 <+6787>: ja 0x555555571915 <main+8133> 0x00005555555713d9 <+6793>: mov 0x29bc0(%rip),%rax # 0x55555559afa0 0x00005555555713e0 <+6800>: mov (%rax,%rbp,8),%rbp 0x00005555555713e4 <+6804>: mov 0x48(%rbp),%rax 0x00005555555713e8 <+6808>: test %rax,%rax 0x00005555555713eb <+6811>: je 0x555555571709 <main+7609> 0x00005555555713f1 <+6817>: call *%rax 0x00005555555713f3 <+6819>: mov %rax,%r12 0x00005555555713f6 <+6822>: test %rax,%rax 0x00005555555713f9 <+6825>: je 0x555555571488 <main+6968> 0x00005555555713ff <+6831>: mov 0x18(%rax),%eax 0x0000555555571402 <+6834>: cmpb $0x0,0x27f37(%rip) # 0x555555599340 0x0000555555571409 <+6841>: mov %eax,0x28(%rsp) 0x000055555557140d <+6845>: je 0x555555571422 <main+6866> 0x000055555557140f <+6847>: mov (%r12),%rax 0x0000555555571413 <+6851>: mov %r12,%rdi 0x0000555555571416 <+6854>: call *0x68(%rax) 0x0000555555571419 <+6857>: test %rax,%rax 0x000055555557141c <+6860>: je 0x5555555719a6 <main+8278> 0x0000555555571422 <+6866>: mov %r12,%rsi 0x0000555555571425 <+6869>: mov %r14,%rdi 0x0000555555571428 <+6872>: call *0x24bea(%rip) # 0x555555596018 0x000055555557142e <+6878>: cmpb $0x0,0x28feb(%rip) # 0x55555559a420 0x0000555555571435 <+6885>: jne 0x555555571962 <main+8210> 0x000055555557143b <+6891>: cmpb $0x0,0x2807e(%rip) # 0x5555555994c0 0x0000555555571442 <+6898>: je 0x555555571488 <main+6968> 0x0000555555571444 <+6900>: mov 0xe8(%rsp),%rax 0x000055555557144c <+6908>: mov 0x88(%rax),%rsi 0x0000555555571453 <+6915>: mov 0x28(%rsp),%eax 0x0000555555571457 <+6919>: cmp $0x2,%eax 0x000055555557145a <+6922>: je 0x555555571a82 <main+8498> 0x0000555555571460 <+6928>: ja 0x5555555716e5 <main+7573> 0x0000555555571466 <+6934>: test %eax,%eax 0x0000555555571468 <+6936>: je 0x555555571a69 <main+8473> 0x000055555557146e <+6942>: mov %rbp,%rdi 0x0000555555571471 <+6945>: addr32 call 0x555555581430 <_ZN4llvm21createLoopPassPrinterEPKNS_8PassInfoERNS_11raw_ostreamE> 0x0000555555571477 <+6951>: mov %r14,%rdi 0x000055555557147a <+6954>: mov %rax,%rsi 0x000055555557147d <+6957>: call 0x55555558b600 0x0000555555571482 <+6962>: nopw 0x0(%rax,%rax,1) 0x0000555555571488 <+6968>: cmpb $0x0,0x295d1(%rip) # 0x55555559aa60 0x000055555557148f <+6975>: je 0x5555555712d8 <main+6536> 0x0000555555571495 <+6981>: mov 0x38(%rsp),%rbp 0x000055555557149a <+6986>: lea 0x1dd90(%rip),%rsi # 0x55555558f231 0x00005555555714a1 <+6993>: movzbl 0x27a57(%rip),%r12d # 0x555555598f00 0x00005555555714a9 <+7001>: mov %rbp,%rdi 0x00005555555714ac <+7004>: call 0x555555587e30 0x00005555555714b1 <+7009>: call *0x24f21(%rip) # 0x5555555963d8 0x00005555555714b7 <+7015>: mov %r12d,%edx 0x00005555555714ba <+7018>: mov %rbp,%rsi 0x00005555555714bd <+7021>: mov %rax,%rdi 0x00005555555714c0 <+7024>: call *0x24c9a(%rip) # 0x555555596160 0x00005555555714c6 <+7030>: mov %r14,%rdi 0x00005555555714c9 <+7033>: mov %rax,%rsi 0x00005555555714cc <+7036>: call 0x55555558b600 0x00005555555714d1 <+7041>: mov 0x270(%rsp),%rdi 0x00005555555714d9 <+7049>: lea 0x280(%rsp),%rax 0x00005555555714e1 <+7057>: cmp %rax,%rdi 0x00005555555714e4 <+7060>: je 0x5555555712d8 <main+6536> 0x00005555555714ea <+7066>: mov 0x280(%rsp),%rax 0x00005555555714f2 <+7074>: lea 0x1(%rax),%rsi 0x00005555555714f6 <+7078>: call *0x24b94(%rip) # 0x555555596090 0x00005555555714fc <+7084>: jmp 0x5555555712d8 <main+6536> 0x0000555555571501 <+7089>: call *0x24ed1(%rip) # 0x5555555963d8 0x0000555555571507 <+7095>: lea 0x1db52(%rip),%rsi # 0x55555558f060 0x000055555557150e <+7102>: mov $0x1,%r12d 0x0000555555571514 <+7108>: lea 0xe8(%rsp),%rbp 0x000055555557151c <+7116>: mov %rax,%rdi 0x000055555557151f <+7119>: call 0x555555576a00 0x0000555555571524 <+7124>: jmp 0x555555570829 <main+3801> 0x0000555555571529 <+7129>: call *0x24ea9(%rip) # 0x5555555963d8 0x000055555557152f <+7135>: mov $0x1,%r12d 0x0000555555571535 <+7141>: mov 0x10(%rsp),%rdi 0x000055555557153a <+7146>: mov $0x1,%r8d 0x0000555555571540 <+7152>: mov %rax,%rdx 0x0000555555571543 <+7155>: mov 0xb0(%rsp),%rax 0x000055555557154b <+7163>: mov $0x1,%ecx 0x0000555555571550 <+7168>: mov (%rax),%rsi 0x0000555555571553 <+7171>: call *0x25697(%rip) # 0x555555596bf0 0x0000555555571559 <+7177>: jmp 0x5555555708c4 <main+3956> 0x000055555557155e <+7182>: call *0x24e74(%rip) # 0x5555555963d8 0x0000555555571564 <+7188>: mov $0x1,%r12d 0x000055555557156a <+7194>: mov %rax,%rdi 0x000055555557156d <+7197>: mov 0xb0(%rsp),%rax 0x0000555555571575 <+7205>: mov (%rax),%rsi 0x0000555555571578 <+7208>: call 0x555555576a00 0x000055555557157d <+7213>: lea 0x1c916(%rip),%rsi # 0x55555558de9a 0x0000555555571584 <+7220>: mov %rax,%rdi 0x0000555555571587 <+7223>: call 0x555555576a00 0x000055555557158c <+7228>: mov 0x29755(%rip),%rdx # 0x55555559ace8 0x0000555555571593 <+7235>: mov 0x29746(%rip),%rsi # 0x55555559ace0 0x000055555557159a <+7242>: mov %rax,%rdi 0x000055555557159d <+7245>: call *0x2552d(%rip) # 0x555555596ad0 0x00005555555715a3 <+7251>: lea 0x1da2e(%rip),%rsi # 0x55555558efd8 0x00005555555715aa <+7258>: mov %rax,%rdi 0x00005555555715ad <+7261>: call 0x555555576a00 0x00005555555715b2 <+7266>: jmp 0x5555555708c4 <main+3956> 0x00005555555715b7 <+7271>: cmpb $0x0,0x29322(%rip) # 0x55555559a8e0 0x00005555555715be <+7278>: jne 0x5555555705b9 <main+3177> 0x00005555555715c4 <+7284>: mov 0xe8(%rsp),%rax 0x00005555555715cc <+7292>: mov 0x88(%rax),%rdi 0x00005555555715d3 <+7299>: call *0x24a5f(%rip) # 0x555555596038 0x00005555555715d9 <+7305>: test %al,%al 0x00005555555715db <+7307>: je 0x5555555705b9 <main+3177> 0x00005555555715e1 <+7313>: cmpq $0x0,0x293e7(%rip) # 0x55555559a9d0 0x00005555555715e9 <+7321>: movb $0x1,0xc9(%rsp) 0x00005555555715f1 <+7329>: movb $0x1,0x293a8(%rip) # 0x55555559a9a0 0x00005555555715f8 <+7336>: je 0x55555557268e <main+11582> 0x00005555555715fe <+7342>: lea 0xc9(%rsp),%rsi 0x0000555555571606 <+7350>: lea 0x293b3(%rip),%rdi # 0x55555559a9c0 0x000055555557160d <+7357>: call *0x293c5(%rip) # 0x55555559a9d8 0x0000555555571613 <+7363>: jmp 0x5555555705b9 <main+3177> 0x0000555555571618 <+7368>: call *0x24dba(%rip) # 0x5555555963d8 0x000055555557161e <+7374>: mov 0x148(%rsp),%rsi 0x0000555555571626 <+7382>: mov 0x140(%rsp),%edx 0x000055555557162d <+7389>: lea 0x420(%rsp),%rdi 0x0000555555571635 <+7397>: mov %rax,%r12 0x0000555555571638 <+7400>: mov (%rsi),%rax 0x000055555557163b <+7403>: call *0x20(%rax) 0x000055555557163e <+7406>: mov %r12,%rdi 0x0000555555571641 <+7409>: mov 0x428(%rsp),%rdx 0x0000555555571649 <+7417>: mov 0x420(%rsp),%rsi 0x0000555555571651 <+7425>: call *0x25479(%rip) # 0x555555596ad0 0x0000555555571657 <+7431>: mov %rax,%rdi 0x000055555557165a <+7434>: mov 0x18(%rax),%rax 0x000055555557165e <+7438>: cmp %rax,0x10(%rdi) 0x0000555555571662 <+7442>: jbe 0x5555555721b0 <main+10336> 0x0000555555571668 <+7448>: lea 0x1(%rax),%rdx 0x000055555557166c <+7452>: mov %rdx,0x18(%rdi) 0x0000555555571670 <+7456>: movb $0xa,(%rax) 0x0000555555571673 <+7459>: mov 0x420(%rsp),%rdi 0x000055555557167b <+7467>: lea 0x430(%rsp),%rax 0x0000555555571683 <+7475>: lea 0xf0(%rsp),%r13 0x000055555557168b <+7483>: cmp %rax,%rdi 0x000055555557168e <+7486>: je 0x5555555716a2 <main+7506> 0x0000555555571690 <+7488>: mov 0x430(%rsp),%rax 0x0000555555571698 <+7496>: lea 0x1(%rax),%rsi 0x000055555557169c <+7500>: call *0x249ee(%rip) # 0x555555596090 0x00005555555716a2 <+7506>: mov $0x1,%r12d 0x00005555555716a8 <+7512>: jmp 0x5555555708b4 <main+3940> 0x00005555555716ad <+7517>: test %r13,%r13 0x00005555555716b0 <+7520>: je 0x555555570ca8 <main+4952> 0x00005555555716b6 <+7526>: mov %rbp,%rdi 0x00005555555716b9 <+7529>: mov %r13,%rdx 0x00005555555716bc <+7532>: mov %r12,%rsi 0x00005555555716bf <+7535>: call *0x2515b(%rip) # 0x555555596820 0x00005555555716c5 <+7541>: jmp 0x555555570ca8 <main+4952> 0x00005555555716ca <+7546>: mov 0x30(%rsp),%rdi 0x00005555555716cf <+7551>: call *0x24ee3(%rip) # 0x5555555965b8 0x00005555555716d5 <+7557>: jmp 0x5555555710e7 <main+6039> 0x00005555555716da <+7562>: mov $0x2,%r12d 0x00005555555716e0 <+7568>: jmp 0x5555555703a6 <main+2646> 0x00005555555716e5 <+7573>: cmpl $0x3,0x28(%rsp) 0x00005555555716ea <+7578>: jne 0x555555571a50 <main+8448> 0x00005555555716f0 <+7584>: mov %rbp,%rdi 0x00005555555716f3 <+7587>: addr32 call 0x555555580df0 <_ZN4llvm26createCallGraphPassPrinterEPKNS_8PassInfoERNS_11raw_ostreamE> 0x00005555555716f9 <+7593>: mov %r14,%rdi 0x00005555555716fc <+7596>: mov %rax,%rsi 0x00005555555716ff <+7599>: call 0x55555558b600 0x0000555555571704 <+7604>: jmp 0x555555571488 <main+6968> 0x0000555555571709 <+7609>: call *0x24cc9(%rip) # 0x5555555963d8 0x000055555557170f <+7615>: mov %rax,%rdi 0x0000555555571712 <+7618>: mov 0xb0(%rsp),%rax 0x000055555557171a <+7626>: mov (%rax),%rsi 0x000055555557171d <+7629>: call 0x555555576a00 0x0000555555571722 <+7634>: lea 0x1db64(%rip),%rsi # 0x55555558f28d 0x0000555555571729 <+7641>: mov %rax,%rdi 0x000055555557172c <+7644>: call 0x555555576a00 0x0000555555571731 <+7649>: mov 0x0(%rbp),%rsi 0x0000555555571735 <+7653>: mov 0x8(%rbp),%rdx 0x0000555555571739 <+7657>: mov %rax,%rdi 0x000055555557173c <+7660>: call 0x5555555769a0 0x0000555555571741 <+7665>: lea 0x1dae8(%rip),%rsi # 0x55555558f230 0x0000555555571748 <+7672>: mov %rax,%rdi 0x000055555557174b <+7675>: call 0x555555576a00 0x0000555555571750 <+7680>: jmp 0x555555571488 <main+6968> 0x0000555555571755 <+7685>: mov %r14,%rdi 0x0000555555571758 <+7688>: call 0x555555585c00 0x000055555557175d <+7693>: cmpq $0x0,0x2886b(%rip) # 0x555555599fd0 0x0000555555571765 <+7701>: movb $0x0,0xcb(%rsp) 0x000055555557176d <+7709>: movb $0x0,0x2882c(%rip) # 0x555555599fa0 0x0000555555571774 <+7716>: je 0x55555557268e <main+11582> 0x000055555557177a <+7722>: mov 0x68(%rsp),%rsi 0x000055555557177f <+7727>: lea 0x2883a(%rip),%rdi # 0x555555599fc0 0x0000555555571786 <+7734>: call *0x2884c(%rip) # 0x555555599fd8 0x000055555557178c <+7740>: jmp 0x555555571319 <main+6601> 0x0000555555571791 <+7745>: xor %r8d,%r8d 0x0000555555571794 <+7748>: xor %ecx,%ecx 0x0000555555571796 <+7750>: mov %r15,%rdx 0x0000555555571799 <+7753>: mov %r13,%rsi 0x000055555557179c <+7756>: mov %r14,%rdi 0x000055555557179f <+7759>: call 0x555555585f20 0x00005555555717a4 <+7764>: cmpq $0x0,0x28764(%rip) # 0x555555599f10 0x00005555555717ac <+7772>: movb $0x0,0xcc(%rsp) 0x00005555555717b4 <+7780>: movb $0x0,0x28725(%rip) # 0x555555599ee0 0x00005555555717bb <+7787>: je 0x55555557268e <main+11582> 0x00005555555717c1 <+7793>: lea 0xcc(%rsp),%rsi 0x00005555555717c9 <+7801>: lea 0x28730(%rip),%rdi # 0x555555599f00 0x00005555555717d0 <+7808>: call *0x28742(%rip) # 0x555555599f18 0x00005555555717d6 <+7814>: jmp 0x555555571339 <main+6633> 0x00005555555717db <+7819>: xor %r8d,%r8d 0x00005555555717de <+7822>: mov $0x1,%ecx 0x00005555555717e3 <+7827>: mov %r15,%rdx 0x00005555555717e6 <+7830>: mov %r13,%rsi 0x00005555555717e9 <+7833>: mov %r14,%rdi 0x00005555555717ec <+7836>: call 0x555555585f20 0x00005555555717f1 <+7841>: cmpq $0x0,0x28657(%rip) # 0x555555599e50 0x00005555555717f9 <+7849>: movb $0x0,0xcd(%rsp) 0x0000555555571801 <+7857>: movb $0x0,0x28618(%rip) # 0x555555599e20 0x0000555555571808 <+7864>: je 0x55555557268e <main+11582> 0x000055555557180e <+7870>: lea 0xcd(%rsp),%rsi 0x0000555555571816 <+7878>: lea 0x28623(%rip),%rdi # 0x555555599e40 0x000055555557181d <+7885>: call *0x28635(%rip) # 0x555555599e58 0x0000555555571823 <+7891>: jmp 0x555555571359 <main+6665> 0x0000555555571828 <+7896>: xor %r8d,%r8d 0x000055555557182b <+7899>: mov $0x2,%ecx 0x0000555555571830 <+7904>: mov %r15,%rdx 0x0000555555571833 <+7907>: mov %r13,%rsi 0x0000555555571836 <+7910>: mov %r14,%rdi 0x0000555555571839 <+7913>: call 0x555555585f20 0x000055555557183e <+7918>: cmpq $0x0,0x2854a(%rip) # 0x555555599d90 0x0000555555571846 <+7926>: movb $0x0,0xce(%rsp) 0x000055555557184e <+7934>: movb $0x0,0x2850b(%rip) # 0x555555599d60 0x0000555555571855 <+7941>: je 0x55555557268e <main+11582> 0x000055555557185b <+7947>: lea 0xce(%rsp),%rsi 0x0000555555571863 <+7955>: lea 0x28516(%rip),%rdi # 0x555555599d80 0x000055555557186a <+7962>: call *0x28528(%rip) # 0x555555599d98 0x0000555555571870 <+7968>: jmp 0x555555571379 <main+6697> 0x0000555555571875 <+7973>: mov $0x1,%r8d 0x000055555557187b <+7979>: mov %r15,%rdx 0x000055555557187e <+7982>: mov %r13,%rsi 0x0000555555571881 <+7985>: mov %r14,%rdi 0x0000555555571884 <+7988>: mov $0x2,%ecx 0x0000555555571889 <+7993>: call 0x555555585f20 0x000055555557188e <+7998>: cmpq $0x0,0x2843a(%rip) # 0x555555599cd0 0x0000555555571896 <+8006>: movb $0x0,0xcf(%rsp) 0x000055555557189e <+8014>: movb $0x0,0x283fb(%rip) # 0x555555599ca0 0x00005555555718a5 <+8021>: je 0x55555557268e <main+11582> 0x00005555555718ab <+8027>: lea 0xcf(%rsp),%rsi 0x00005555555718b3 <+8035>: lea 0x28406(%rip),%rdi # 0x555555599cc0 0x00005555555718ba <+8042>: call *0x28418(%rip) # 0x555555599cd8 0x00005555555718c0 <+8048>: jmp 0x555555571399 <main+6729> 0x00005555555718c5 <+8053>: mov $0x2,%r8d 0x00005555555718cb <+8059>: mov %r15,%rdx 0x00005555555718ce <+8062>: mov %r13,%rsi 0x00005555555718d1 <+8065>: mov %r14,%rdi 0x00005555555718d4 <+8068>: mov $0x2,%ecx 0x00005555555718d9 <+8073>: call 0x555555585f20 0x00005555555718de <+8078>: cmpq $0x0,0x2832a(%rip) # 0x555555599c10 0x00005555555718e6 <+8086>: movb $0x0,0xf8(%rsp) 0x00005555555718ee <+8094>: movb $0x0,0x282eb(%rip) # 0x555555599be0 0x00005555555718f5 <+8101>: je 0x55555557268e <main+11582> 0x00005555555718fb <+8107>: lea 0xf8(%rsp),%rsi 0x0000555555571903 <+8115>: lea 0x282f6(%rip),%rdi # 0x555555599c00 0x000055555557190a <+8122>: call *0x28308(%rip) # 0x555555599c18 0x0000555555571910 <+8128>: jmp 0x5555555713b9 <main+6761> 0x0000555555571915 <+8133>: xor %r8d,%r8d 0x0000555555571918 <+8136>: mov $0x3,%ecx 0x000055555557191d <+8141>: mov %r15,%rdx 0x0000555555571920 <+8144>: mov %r13,%rsi 0x0000555555571923 <+8147>: mov %r14,%rdi 0x0000555555571926 <+8150>: call 0x555555585f20 0x000055555557192b <+8155>: cmpq $0x0,0x2821d(%rip) # 0x555555599b50 0x0000555555571933 <+8163>: movb $0x0,0x100(%rsp) 0x000055555557193b <+8171>: movb $0x0,0x281de(%rip) # 0x555555599b20 0x0000555555571942 <+8178>: je 0x55555557268e <main+11582> 0x0000555555571948 <+8184>: lea 0x100(%rsp),%rsi 0x0000555555571950 <+8192>: lea 0x281e9(%rip),%rdi # 0x555555599b40 0x0000555555571957 <+8199>: call *0x281fb(%rip) # 0x555555599b58 0x000055555557195d <+8205>: jmp 0x5555555713d9 <main+6793> 0x0000555555571962 <+8210>: mov $0x1,%edi 0x0000555555571967 <+8215>: call *0x25413(%rip) # 0x555555596d80 0x000055555557196d <+8221>: cmpb $0x0,0x279cc(%rip) # 0x555555599340 0x0000555555571974 <+8228>: mov %rax,%r8 0x0000555555571977 <+8231>: je 0x555555571995 <main+8261> 0x0000555555571979 <+8233>: mov (%rax),%rax 0x000055555557197c <+8236>: mov %r8,0x58(%rsp) 0x0000555555571981 <+8241>: mov %r8,%rdi 0x0000555555571984 <+8244>: call *0x68(%rax) 0x0000555555571987 <+8247>: mov 0x58(%rsp),%r8 0x000055555557198c <+8252>: test %rax,%rax 0x000055555557198f <+8255>: je 0x555555571a9b <main+8523> 0x0000555555571995 <+8261>: mov %r8,%rsi 0x0000555555571998 <+8264>: mov %r14,%rdi 0x000055555557199b <+8267>: call *0x24677(%rip) # 0x555555596018 0x00005555555719a1 <+8273>: jmp 0x55555557143b <main+6891> 0x00005555555719a6 <+8278>: mov %r12,%rdi 0x00005555555719a9 <+8281>: call *0x252b1(%rip) # 0x555555596c60 0x00005555555719af <+8287>: test %al,%al 0x00005555555719b1 <+8289>: jne 0x555555571422 <main+6866> 0x00005555555719b7 <+8295>: mov %r12,%rdi 0x00005555555719ba <+8298>: call *0x252d8(%rip) # 0x555555596c98 0x00005555555719c0 <+8304>: test %al,%al 0x00005555555719c2 <+8306>: jne 0x555555571422 <main+6866> 0x00005555555719c8 <+8312>: mov 0x18(%r12),%ecx 0x00005555555719cd <+8317>: mov (%r12),%rax 0x00005555555719d1 <+8321>: mov %r12,%rdi 0x00005555555719d4 <+8324>: mov %ecx,0x58(%rsp) 0x00005555555719d8 <+8328>: call *0x10(%rax) 0x00005555555719db <+8331>: mov 0x58(%rsp),%ecx 0x00005555555719df <+8335>: cmp $0x2,%ecx 0x00005555555719e2 <+8338>: je 0x555555571fb6 <main+9830> 0x00005555555719e8 <+8344>: cmp $0x4,%ecx 0x00005555555719eb <+8347>: jne 0x555555571422 <main+6866> 0x00005555555719f1 <+8353>: mov %rdx,0x80(%rsp) 0x00005555555719f9 <+8361>: mov %rax,0x58(%rsp) 0x00005555555719fe <+8366>: call *0x24684(%rip) # 0x555555596088 0x0000555555571a04 <+8372>: mov %r14,%rdi 0x0000555555571a07 <+8375>: mov %rax,%rsi 0x0000555555571a0a <+8378>: call *0x24608(%rip) # 0x555555596018 0x0000555555571a10 <+8384>: mov %r12,%rsi 0x0000555555571a13 <+8387>: mov %r14,%rdi 0x0000555555571a16 <+8390>: call *0x245fc(%rip) # 0x555555596018 0x0000555555571a1c <+8396>: mov 0x58(%rsp),%r9 0x0000555555571a21 <+8401>: mov $0x1,%edi 0x0000555555571a26 <+8406>: mov 0x80(%rsp),%rdx 0x0000555555571a2e <+8414>: lea 0x150(%rsp),%rcx 0x0000555555571a36 <+8422>: mov %r9,%rsi 0x0000555555571a39 <+8425>: call *0x24659(%rip) # 0x555555596098 0x0000555555571a3f <+8431>: mov %r14,%rdi 0x0000555555571a42 <+8434>: mov %rax,%rsi 0x0000555555571a45 <+8437>: call *0x245cd(%rip) # 0x555555596018 0x0000555555571a4b <+8443>: jmp 0x55555557142e <main+6878> 0x0000555555571a50 <+8448>: mov %rbp,%rdi 0x0000555555571a53 <+8451>: addr32 call 0x555555581110 <_ZN4llvm23createModulePassPrinterEPKNS_8PassInfoERNS_11raw_ostreamE> 0x0000555555571a59 <+8457>: mov %r14,%rdi 0x0000555555571a5c <+8460>: mov %rax,%rsi 0x0000555555571a5f <+8463>: call 0x55555558b600 0x0000555555571a64 <+8468>: jmp 0x555555571488 <main+6968> 0x0000555555571a69 <+8473>: mov %rbp,%rdi 0x0000555555571a6c <+8476>: addr32 call 0x555555581750 <_ZN4llvm23createRegionPassPrinterEPKNS_8PassInfoERNS_11raw_ostreamE> 0x0000555555571a72 <+8482>: mov %r14,%rdi 0x0000555555571a75 <+8485>: mov %rax,%rsi 0x0000555555571a78 <+8488>: call 0x55555558b600 0x0000555555571a7d <+8493>: jmp 0x555555571488 <main+6968> 0x0000555555571a82 <+8498>: mov %rbp,%rdi 0x0000555555571a85 <+8501>: addr32 call 0x555555580ad0 <_ZN4llvm25createFunctionPassPrinterEPKNS_8PassInfoERNS_11raw_ostreamE> 0x0000555555571a8b <+8507>: mov %r14,%rdi 0x0000555555571a8e <+8510>: mov %rax,%rsi 0x0000555555571a91 <+8513>: call 0x55555558b600 0x0000555555571a96 <+8518>: jmp 0x555555571488 <main+6968> 0x0000555555571a9b <+8523>: mov %r8,%rdi 0x0000555555571a9e <+8526>: call *0x251bc(%rip) # 0x555555596c60 0x0000555555571aa4 <+8532>: mov 0x58(%rsp),%r8 0x0000555555571aa9 <+8537>: test %al,%al 0x0000555555571aab <+8539>: jne 0x555555571995 <main+8261> 0x0000555555571ab1 <+8545>: mov %r8,%rdi 0x0000555555571ab4 <+8548>: call *0x251de(%rip) # 0x555555596c98 0x0000555555571aba <+8554>: mov 0x58(%rsp),%r8 0x0000555555571abf <+8559>: test %al,%al 0x0000555555571ac1 <+8561>: jne 0x555555571995 <main+8261> 0x0000555555571ac7 <+8567>: mov 0x18(%r8),%ecx 0x0000555555571acb <+8571>: mov (%r8),%rax 0x0000555555571ace <+8574>: mov %r8,%rdi 0x0000555555571ad1 <+8577>: mov %ecx,0x80(%rsp) 0x0000555555571ad8 <+8584>: call *0x10(%rax) 0x0000555555571adb <+8587>: mov 0x80(%rsp),%ecx 0x0000555555571ae2 <+8594>: mov 0x58(%rsp),%r8 0x0000555555571ae7 <+8599>: cmp $0x2,%ecx 0x0000555555571aea <+8602>: je 0x5555555724c1 <main+11121> 0x0000555555571af0 <+8608>: cmp $0x4,%ecx 0x0000555555571af3 <+8611>: jne 0x555555571995 <main+8261> 0x0000555555571af9 <+8617>: mov %rdx,0x88(%rsp) 0x0000555555571b01 <+8625>: mov %r8,0x58(%rsp) 0x0000555555571b06 <+8630>: mov %rax,0x80(%rsp) 0x0000555555571b0e <+8638>: call *0x24574(%rip) # 0x555555596088 0x0000555555571b14 <+8644>: mov %r14,%rdi 0x0000555555571b17 <+8647>: mov %rax,%rsi 0x0000555555571b1a <+8650>: call *0x244f8(%rip) # 0x555555596018 0x0000555555571b20 <+8656>: mov 0x58(%rsp),%r8 0x0000555555571b25 <+8661>: mov %r14,%rdi 0x0000555555571b28 <+8664>: mov %r8,%rsi 0x0000555555571b2b <+8667>: call *0x244e7(%rip) # 0x555555596018 0x0000555555571b31 <+8673>: mov 0x80(%rsp),%r9 0x0000555555571b39 <+8681>: mov $0x1,%edi 0x0000555555571b3e <+8686>: mov 0x88(%rsp),%rdx 0x0000555555571b46 <+8694>: lea 0x150(%rsp),%rcx 0x0000555555571b4e <+8702>: mov %r9,%rsi 0x0000555555571b51 <+8705>: call *0x24541(%rip) # 0x555555596098 0x0000555555571b57 <+8711>: mov %r14,%rdi 0x0000555555571b5a <+8714>: mov %rax,%rsi 0x0000555555571b5d <+8717>: call *0x244b5(%rip) # 0x555555596018 0x0000555555571b63 <+8723>: jmp 0x55555557143b <main+6891> 0x0000555555571b68 <+8728>: lea 0x1d690(%rip),%rsi # 0x55555558f1ff 0x0000555555571b6f <+8735>: mov %rax,%rdi 0x0000555555571b72 <+8738>: call *0x24b00(%rip) # 0x555555596678 0x0000555555571b78 <+8744>: test %eax,%eax 0x0000555555571b7a <+8746>: jne 0x555555570a6c <main+4380> 0x0000555555571b80 <+8752>: movq $0x0,0x18(%rsp) 0x0000555555571b89 <+8761>: jmp 0x55555557056c <main+3100> 0x0000555555571b8e <+8766>: mov 0x78(%rsp),%r15 0x0000555555571b93 <+8771>: cmpb $0x0,0x28406(%rip) # 0x555555599fa0 0x0000555555571b9a <+8778>: jne 0x5555555722aa <main+10586> 0x0000555555571ba0 <+8784>: cmpb $0x0,0x28339(%rip) # 0x555555599ee0 0x0000555555571ba7 <+8791>: jne 0x555555572290 <main+10560> 0x0000555555571bad <+8797>: cmpb $0x0,0x2826c(%rip) # 0x555555599e20 0x0000555555571bb4 <+8804>: jne 0x555555572273 <main+10531> 0x0000555555571bba <+8810>: cmpb $0x0,0x2819f(%rip) # 0x555555599d60 0x0000555555571bc1 <+8817>: jne 0x555555572256 <main+10502> 0x0000555555571bc7 <+8823>: cmpb $0x0,0x280d2(%rip) # 0x555555599ca0 0x0000555555571bce <+8830>: jne 0x555555572213 <main+10435> 0x0000555555571bd4 <+8836>: cmpb $0x0,0x28005(%rip) # 0x555555599be0 0x0000555555571bdb <+8843>: jne 0x5555555721f3 <main+10403> 0x0000555555571be1 <+8849>: cmpb $0x0,0x27f38(%rip) # 0x555555599b20 0x0000555555571be8 <+8856>: jne 0x5555555721d6 <main+10374> 0x0000555555571bee <+8862>: test %r13,%r13 0x0000555555571bf1 <+8865>: je 0x555555571c36 <main+8934> 0x0000555555571bf3 <+8867>: mov %r13,%rdi 0x0000555555571bf6 <+8870>: call *0x24404(%rip) # 0x555555596000 0x0000555555571bfc <+8876>: mov 0xe0(%rsp),%rbx 0x0000555555571c04 <+8884>: mov 0x20(%rbx),%rbp 0x0000555555571c08 <+8888>: add $0x18,%rbx 0x0000555555571c0c <+8892>: jmp 0x555555571c1f <main+8911> 0x0000555555571c0e <+8894>: lea -0x38(%rbp),%rsi 0x0000555555571c12 <+8898>: mov %r13,%rdi 0x0000555555571c15 <+8901>: call *0x249c5(%rip) # 0x5555555965e0 0x0000555555571c1b <+8907>: mov 0x8(%rbp),%rbp 0x0000555555571c1f <+8911>: cmp %rbp,%rbx 0x0000555555571c22 <+8914>: je 0x555555571c2d <main+8925> 0x0000555555571c24 <+8916>: test %rbp,%rbp 0x0000555555571c27 <+8919>: jne 0x555555571c0e <main+8894> 0x0000555555571c29 <+8921>: xor %esi,%esi 0x0000555555571c2b <+8923>: jmp 0x555555571c12 <main+8898> 0x0000555555571c2d <+8925>: mov %r13,%rdi 0x0000555555571c30 <+8928>: call *0x247ea(%rip) # 0x555555596420 0x0000555555571c36 <+8934>: cmpb $0x0,0x28963(%rip) # 0x55555559a5a0 0x0000555555571c3d <+8941>: jne 0x555555571c4c <main+8956> 0x0000555555571c3f <+8943>: cmpb $0x0,0x287da(%rip) # 0x55555559a420 0x0000555555571c46 <+8950>: je 0x555555572572 <main+11298> 0x0000555555571c4c <+8956>: cmpb $0x0,0x70(%rsp) 0x0000555555571c51 <+8961>: jne 0x555555572233 <main+10467> 0x0000555555571c57 <+8967>: lea 0x118(%rsp),%rax 0x0000555555571c5f <+8975>: pxor %xmm0,%xmm0 0x0000555555571c63 <+8979>: cmpb $0x0,0x28d36(%rip) # 0x55555559a9a0 0x0000555555571c6a <+8986>: movzbl 0x271cf(%rip),%ebx # 0x555555598e40 0x0000555555571c71 <+8993>: mov %rax,0x58(%rsp) 0x0000555555571c76 <+8998>: mov %rax,0x100(%rsp) 0x0000555555571c7e <+9006>: lea 0x138(%rsp),%rax 0x0000555555571c86 <+9014>: mov %rax,0x28(%rsp) 0x0000555555571c8b <+9019>: mov %rax,0x120(%rsp) 0x0000555555571c93 <+9027>: movups %xmm0,0x108(%rsp) 0x0000555555571c9b <+9035>: movups %xmm0,0x128(%rsp) 0x0000555555571ca3 <+9043>: jne 0x555555571eca <main+9594> 0x0000555555571ca9 <+9049>: cmpb $0x0,0x27810(%rip) # 0x5555555994c0 0x0000555555571cb0 <+9056>: jne 0x555555571eca <main+9594> 0x0000555555571cb6 <+9062>: mov 0xe8(%rsp),%rax 0x0000555555571cbe <+9070>: mov 0x88(%rax),%r12 0x0000555555571cc5 <+9077>: test %bl,%bl 0x0000555555571cc7 <+9079>: jne 0x5555555726db <main+11659> 0x0000555555571ccd <+9085>: mov $0x1,%ebx 0x0000555555571cd2 <+9090>: xor %ebp,%ebp 0x0000555555571cd4 <+9092>: cmpb $0x0,0x28c05(%rip) # 0x55555559a8e0 0x0000555555571cdb <+9099>: je 0x5555555722ff <main+10671> 0x0000555555571ce1 <+9105>: cmpb $0x0,0x27af8(%rip) # 0x5555555997e0 0x0000555555571ce8 <+9112>: jne 0x5555555726c9 <main+11641> 0x0000555555571cee <+9118>: cmpb $0x0,0x27a2b(%rip) # 0x555555599720 0x0000555555571cf5 <+9125>: jne 0x5555555726b7 <main+11623> 0x0000555555571cfb <+9131>: movzbl 0x271fe(%rip),%edx # 0x555555598f00 0x0000555555571d02 <+9138>: mov 0x38(%rsp),%rdi 0x0000555555571d07 <+9143>: lea 0x1d523(%rip),%rsi # 0x55555558f231 0x0000555555571d0e <+9150>: mov %edx,0x60(%rsp) 0x0000555555571d12 <+9154>: call 0x555555587e30 0x0000555555571d17 <+9159>: mov 0x60(%rsp),%edx 0x0000555555571d1b <+9163>: mov 0x38(%rsp),%rsi 0x0000555555571d20 <+9168>: mov %r12,%rdi 0x0000555555571d23 <+9171>: call *0x24437(%rip) # 0x555555596160 0x0000555555571d29 <+9177>: mov %r14,%rdi 0x0000555555571d2c <+9180>: mov %rax,%rsi 0x0000555555571d2f <+9183>: call 0x55555558b600 0x0000555555571d34 <+9188>: mov 0x270(%rsp),%rdi 0x0000555555571d3c <+9196>: lea 0x280(%rsp),%rax 0x0000555555571d44 <+9204>: cmp %rax,%rdi 0x0000555555571d47 <+9207>: je 0x555555571d5b <main+9227> 0x0000555555571d49 <+9209>: mov 0x280(%rsp),%rax 0x0000555555571d51 <+9217>: lea 0x1(%rax),%rsi 0x0000555555571d55 <+9221>: call *0x24335(%rip) # 0x555555596090 0x0000555555571d5b <+9227>: call *0x2480f(%rip) # 0x555555596570 0x0000555555571d61 <+9233>: cmpb $0x0,0x270d8(%rip) # 0x555555598e40 0x0000555555571d68 <+9240>: jne 0x555555572082 <main+10034> 0x0000555555571d6e <+9246>: mov 0xe0(%rsp),%rsi 0x0000555555571d76 <+9254>: mov %r14,%rdi 0x0000555555571d79 <+9257>: call *0x245a9(%rip) # 0x555555596328 0x0000555555571d7f <+9263>: cmpb $0x0,0x275ba(%rip) # 0x555555599340 0x0000555555571d86 <+9270>: je 0x555555571d98 <main+9288> 0x0000555555571d88 <+9272>: mov 0x274b9(%rip),%rsi # 0x555555599248 0x0000555555571d8f <+9279>: test %rsi,%rsi 0x0000555555571d92 <+9282>: jne 0x55555557258d <main+11325> 0x0000555555571d98 <+9288>: cmpb $0x0,0x28c01(%rip) # 0x55555559a9a0 0x0000555555571d9f <+9295>: je 0x555555571daa <main+9306> 0x0000555555571da1 <+9297>: cmpb $0x0,0x273d8(%rip) # 0x555555599180 0x0000555555571da8 <+9304>: je 0x555555571db6 <main+9318> 0x0000555555571daa <+9306>: mov 0xe8(%rsp),%rax 0x0000555555571db2 <+9314>: movb $0x1,0x20(%rax) 0x0000555555571db6 <+9318>: mov 0xd8(%rsp),%rax 0x0000555555571dbe <+9326>: test %rax,%rax 0x0000555555571dc1 <+9329>: je 0x555555571dc7 <main+9335> 0x0000555555571dc3 <+9331>: movb $0x1,0x20(%rax) 0x0000555555571dc7 <+9335>: mov 0xf0(%rsp),%rax 0x0000555555571dcf <+9343>: test %rax,%rax 0x0000555555571dd2 <+9346>: je 0x5555555724b9 <main+11113> 0x0000555555571dd8 <+9352>: movb $0x1,0x20(%rax) 0x0000555555571ddc <+9356>: xor %r12d,%r12d 0x0000555555571ddf <+9359>: test %rbp,%rbp 0x0000555555571de2 <+9362>: je 0x555555571dee <main+9374> 0x0000555555571de4 <+9364>: mov 0x0(%rbp),%rax 0x0000555555571de8 <+9368>: mov %rbp,%rdi 0x0000555555571deb <+9371>: call *0x8(%rax) 0x0000555555571dee <+9374>: mov 0x120(%rsp),%rdi 0x0000555555571df6 <+9382>: cmp 0x28(%rsp),%rdi 0x0000555555571dfb <+9387>: je 0x555555571e03 <main+9395> 0x0000555555571dfd <+9389>: call *0x24aa5(%rip) # 0x5555555968a8 0x0000555555571e03 <+9395>: mov 0x100(%rsp),%rdi 0x0000555555571e0b <+9403>: lea 0xe8(%rsp),%rbp 0x0000555555571e13 <+9411>: cmp 0x58(%rsp),%rdi 0x0000555555571e18 <+9416>: je 0x555555571e20 <main+9424> 0x0000555555571e1a <+9418>: call *0x24a88(%rip) # 0x5555555968a8 0x0000555555571e20 <+9424>: test %r13,%r13 0x0000555555571e23 <+9427>: je 0x555555571e2f <main+9439> 0x0000555555571e25 <+9429>: mov 0x0(%r13),%rax 0x0000555555571e29 <+9433>: mov %r13,%rdi 0x0000555555571e2c <+9436>: call *0x8(%rax) 0x0000555555571e2f <+9439>: mov 0x30(%rsp),%rdi 0x0000555555571e34 <+9444>: call 0x555555588b70 0x0000555555571e39 <+9449>: lea 0x23f88(%rip),%rax # 0x555555595dc8 <_ZTV20OptCustomPassManager> 0x0000555555571e40 <+9456>: mov 0x168(%rsp),%rdi 0x0000555555571e48 <+9464>: add $0x10,%rax 0x0000555555571e4c <+9468>: mov %rax,0x140(%rsp) 0x0000555555571e54 <+9476>: test %rdi,%rdi 0x0000555555571e57 <+9479>: je 0x555555571e6a <main+9498> 0x0000555555571e59 <+9481>: mov 0x178(%rsp),%rsi 0x0000555555571e61 <+9489>: sub %rdi,%rsi 0x0000555555571e64 <+9492>: call *0x24226(%rip) # 0x555555596090 0x0000555555571e6a <+9498>: mov 0x160(%rsp),%esi 0x0000555555571e71 <+9505>: mov 0x150(%rsp),%rdi 0x0000555555571e79 <+9513>: mov $0x8,%edx 0x0000555555571e7e <+9518>: imul $0x18,%rsi,%rsi 0x0000555555571e82 <+9522>: call *0x24380(%rip) # 0x555555596208 0x0000555555571e88 <+9528>: mov %r14,%rdi 0x0000555555571e8b <+9531>: call *0x24637(%rip) # 0x5555555964c8 0x0000555555571e91 <+9537>: jmp 0x555555570829 <main+3801> 0x0000555555571e96 <+9542>: movq %rax,%xmm0 0x0000555555571e9b <+9547>: movq %rsi,%xmm3 0x0000555555571ea0 <+9552>: mov %rdx,0xf0(%rbx) 0x0000555555571ea7 <+9559>: punpcklqdq %xmm3,%xmm0 0x0000555555571eab <+9563>: movups %xmm0,0xf8(%rbx) 0x0000555555571eb2 <+9570>: mov %rbp,0x420(%rsp) 0x0000555555571eba <+9578>: jmp 0x555555570f13 <main+5571> 0x0000555555571ebf <+9583>: mov $0x1,%r12d 0x0000555555571ec5 <+9589>: jmp 0x5555555703a6 <main+2646> 0x0000555555571eca <+9594>: xor %ebp,%ebp 0x0000555555571ecc <+9596>: test %bl,%bl 0x0000555555571ece <+9598>: je 0x555555571d5b <main+9227> 0x0000555555571ed4 <+9604>: mov $0x40,%edi 0x0000555555571ed9 <+9609>: call *0x24991(%rip) # 0x555555596870 0x0000555555571edf <+9615>: xor %ecx,%ecx 0x0000555555571ee1 <+9617>: xor %edx,%edx 0x0000555555571ee3 <+9619>: xor %esi,%esi 0x0000555555571ee5 <+9621>: mov %rax,%r12 0x0000555555571ee8 <+9624>: movb $0x0,0x20(%rax) 0x0000555555571eec <+9628>: movq $0x0,0x28(%rax) 0x0000555555571ef4 <+9636>: mov %r12,%rdi 0x0000555555571ef7 <+9639>: mov %r12,%rbp 0x0000555555571efa <+9642>: movl $0x1,0x30(%rax) 0x0000555555571f01 <+9649>: movq $0x0,0x18(%rax) 0x0000555555571f09 <+9657>: movq $0x0,0x10(%rax) 0x0000555555571f11 <+9665>: movq $0x0,0x8(%rax) 0x0000555555571f19 <+9673>: mov 0x24fd8(%rip),%rax # 0x555555596ef8 0x0000555555571f20 <+9680>: add $0x10,%rax 0x0000555555571f24 <+9684>: mov %rax,(%r12) 0x0000555555571f28 <+9688>: lea 0x100(%rsp),%rax 0x0000555555571f30 <+9696>: mov %rax,0x38(%r12) 0x0000555555571f35 <+9701>: call *0x2480d(%rip) # 0x555555596748 0x0000555555571f3b <+9707>: movzbl 0x60(%rsp),%ebx 0x0000555555571f40 <+9712>: jmp 0x555555571cd4 <main+9092> 0x0000555555571f45 <+9717>: xor %edx,%edx 0x0000555555571f47 <+9719>: mov %r14,%rsi 0x0000555555571f4a <+9722>: call *0x24510(%rip) # 0x555555596460 0x0000555555571f50 <+9728>: mov %rax,0x420(%rsp) 0x0000555555571f58 <+9736>: mov %rax,%rdi 0x0000555555571f5b <+9739>: mov 0x140(%rsp),%rax 0x0000555555571f63 <+9747>: mov %rax,0x430(%rsp) 0x0000555555571f6b <+9755>: jmp 0x5555555716b9 <main+7529> 0x0000555555571f70 <+9760>: movq $0x0,0x18(%rsp) 0x0000555555571f79 <+9769>: jmp 0x5555555704e0 <main+2960> 0x0000555555571f7e <+9774>: mov 0x428(%rsp),%rdx 0x0000555555571f86 <+9782>: test %rdx,%rdx 0x0000555555571f89 <+9785>: je 0x555555570f08 <main+5560> 0x0000555555571f8f <+9791>: cmp $0x1,%rdx 0x0000555555571f93 <+9795>: je 0x55555557249b <main+11083> 0x0000555555571f99 <+9801>: mov %rbp,%rsi 0x0000555555571f9c <+9804>: call *0x2487e(%rip) # 0x555555596820 0x0000555555571fa2 <+9810>: mov 0x428(%rsp),%rdx 0x0000555555571faa <+9818>: mov 0xf0(%rbx),%rdi 0x0000555555571fb1 <+9825>: jmp 0x555555570f08 <main+5560> 0x0000555555571fb6 <+9830>: mov %rdx,0x80(%rsp) 0x0000555555571fbe <+9838>: mov %rax,0x58(%rsp) 0x0000555555571fc3 <+9843>: call *0x24b37(%rip) # 0x555555596b00 0x0000555555571fc9 <+9849>: mov %r14,%rdi 0x0000555555571fcc <+9852>: mov %rax,%rsi 0x0000555555571fcf <+9855>: call *0x24043(%rip) # 0x555555596018 0x0000555555571fd5 <+9861>: mov %r12,%rsi 0x0000555555571fd8 <+9864>: mov %r14,%rdi 0x0000555555571fdb <+9867>: call *0x24037(%rip) # 0x555555596018 0x0000555555571fe1 <+9873>: mov 0x58(%rsp),%r9 0x0000555555571fe6 <+9878>: mov $0x1,%edi 0x0000555555571feb <+9883>: mov 0x80(%rsp),%rdx 0x0000555555571ff3 <+9891>: lea 0x150(%rsp),%rcx 0x0000555555571ffb <+9899>: mov %r9,%rsi 0x0000555555571ffe <+9902>: call *0x24f0c(%rip) # 0x555555596f10 0x0000555555572004 <+9908>: mov %r14,%rdi 0x0000555555572007 <+9911>: mov %rax,%rsi 0x000055555557200a <+9914>: call *0x24008(%rip) # 0x555555596018 0x0000555555572010 <+9920>: jmp 0x55555557142e <main+6878> 0x0000555555572015 <+9925>: mov 0x28(%rsp),%r14 0x000055555557201a <+9930>: call *0x243b8(%rip) # 0x5555555963d8 0x0000555555572020 <+9936>: mov %rax,%rdi 0x0000555555572023 <+9939>: mov 0xb0(%rsp),%rax 0x000055555557202b <+9947>: mov (%rax),%rsi 0x000055555557202e <+9950>: call 0x555555576a00 0x0000555555572033 <+9955>: lea 0x1d066(%rip),%rsi # 0x55555558f0a0 0x000055555557203a <+9962>: mov %rax,%rdi 0x000055555557203d <+9965>: call 0x555555576a00 0x0000555555572042 <+9970>: mov 0x8(%r13),%rdx 0x0000555555572046 <+9974>: mov 0x0(%r13),%rsi 0x000055555557204a <+9978>: mov %rax,%rdi 0x000055555557204d <+9981>: call *0x24a7d(%rip) # 0x555555596ad0 0x0000555555572053 <+9987>: mov %rax,%rdi 0x0000555555572056 <+9990>: mov 0x18(%rax),%rax 0x000055555557205a <+9994>: cmp 0x10(%rdi),%rax 0x000055555557205e <+9998>: jae 0x555555572530 <main+11232> 0x0000555555572064 <+10004>: lea 0x1(%rax),%rdx 0x0000555555572068 <+10008>: mov %rdx,0x18(%rdi) 0x000055555557206c <+10012>: movb $0xa,(%rax) 0x000055555557206f <+10015>: mov $0x1,%r12d 0x0000555555572075 <+10021>: lea 0xe8(%rsp),%rbp 0x000055555557207d <+10029>: jmp 0x555555571e2f <main+9439> 0x0000555555572082 <+10034>: lea 0xf8(%rsp),%r12 0x000055555557208a <+10042>: mov 0xe0(%rsp),%rsi 0x0000555555572092 <+10050>: mov %r12,%rdi 0x0000555555572095 <+10053>: call *0x24085(%rip) # 0x555555596120 0x000055555557209b <+10059>: mov 0xe0(%rsp),%rsi 0x00005555555720a3 <+10067>: mov %r14,%rdi 0x00005555555720a6 <+10070>: call *0x2427c(%rip) # 0x555555596328 0x00005555555720ac <+10076>: mov 0x108(%rsp),%rdx 0x00005555555720b4 <+10084>: mov 0x128(%rsp),%rcx 0x00005555555720bc <+10092>: mov %rdx,%r8 0x00005555555720bf <+10095>: cmp %rcx,%rdx 0x00005555555720c2 <+10098>: jbe 0x555555572540 <main+11248> 0x00005555555720c8 <+10104>: cmp 0x130(%rsp),%rdx 0x00005555555720d0 <+10112>: ja 0x5555555725a7 <main+11351> 0x00005555555720d6 <+10118>: test %rcx,%rcx 0x00005555555720d9 <+10121>: je 0x555555572110 <main+10176> 0x00005555555720db <+10123>: mov %rdx,0x60(%rsp) 0x00005555555720e0 <+10128>: mov 0x100(%rsp),%rsi 0x00005555555720e8 <+10136>: mov %rcx,%rdx 0x00005555555720eb <+10139>: mov %rcx,0x38(%rsp) 0x00005555555720f0 <+10144>: mov 0x120(%rsp),%rdi 0x00005555555720f8 <+10152>: call *0x23fe2(%rip) # 0x5555555960e0 0x00005555555720fe <+10158>: mov 0x60(%rsp),%r8 0x0000555555572103 <+10163>: mov 0x38(%rsp),%rcx 0x0000555555572108 <+10168>: mov 0x108(%rsp),%rdx 0x0000555555572110 <+10176>: mov 0x100(%rsp),%rax 0x0000555555572118 <+10184>: lea (%rax,%rcx,1),%rsi 0x000055555557211c <+10188>: add %rdx,%rax 0x000055555557211f <+10191>: cmp %rax,%rsi 0x0000555555572122 <+10194>: je 0x555555572142 <main+10226> 0x0000555555572124 <+10196>: mov 0x120(%rsp),%rdi 0x000055555557212c <+10204>: mov %r8,0x38(%rsp) 0x0000555555572131 <+10209>: sub %rcx,%rdx 0x0000555555572134 <+10212>: add %rcx,%rdi 0x0000555555572137 <+10215>: call *0x246e3(%rip) # 0x555555596820 0x000055555557213d <+10221>: mov 0x38(%rsp),%r8 0x0000555555572142 <+10226>: mov %r8,0x128(%rsp) 0x000055555557214a <+10234>: movq $0x0,0x108(%rsp) 0x0000555555572156 <+10246>: mov 0xf8(%rsp),%rsi 0x000055555557215e <+10254>: mov %r14,%rdi 0x0000555555572161 <+10257>: call *0x241c1(%rip) # 0x555555596328 0x0000555555572167 <+10263>: mov 0x108(%rsp),%rdx 0x000055555557216f <+10271>: cmp %rdx,0x128(%rsp) 0x0000555555572177 <+10279>: jne 0x555555572339 <main+10729> 0x000055555557217d <+10285>: mov 0x120(%rsp),%rsi 0x0000555555572185 <+10293>: mov 0x100(%rsp),%rdi 0x000055555557218d <+10301>: call *0x244e5(%rip) # 0x555555596678 0x0000555555572193 <+10307>: test %eax,%eax 0x0000555555572195 <+10309>: jne 0x555555572339 <main+10729> 0x000055555557219b <+10315>: test %bl,%bl 0x000055555557219d <+10317>: jne 0x55555557266a <main+11546> 0x00005555555721a3 <+10323>: mov %r12,%rdi 0x00005555555721a6 <+10326>: call 0x55555558a1a0 0x00005555555721ab <+10331>: jmp 0x555555571d7f <main+9263> 0x00005555555721b0 <+10336>: mov $0xa,%esi 0x00005555555721b5 <+10341>: call *0x241ed(%rip) # 0x5555555963a8 0x00005555555721bb <+10347>: jmp 0x555555571673 <main+7459> 0x00005555555721c0 <+10352>: call *0x23ec2(%rip) # 0x555555596088 0x00005555555721c6 <+10358>: mov %r14,%rdi 0x00005555555721c9 <+10361>: mov %rax,%rsi 0x00005555555721cc <+10364>: call 0x55555558b600 0x00005555555721d1 <+10369>: jmp 0x555555571170 <main+6176> 0x00005555555721d6 <+10374>: mov 0x18(%rsp),%rdx 0x00005555555721db <+10379>: xor %r8d,%r8d 0x00005555555721de <+10382>: mov $0x3,%ecx 0x00005555555721e3 <+10387>: mov %r13,%rsi 0x00005555555721e6 <+10390>: mov %r14,%rdi 0x00005555555721e9 <+10393>: call 0x555555585f20 0x00005555555721ee <+10398>: jmp 0x555555571bee <main+8862> 0x00005555555721f3 <+10403>: mov 0x18(%rsp),%rdx 0x00005555555721f8 <+10408>: mov $0x2,%ecx 0x00005555555721fd <+10413>: mov %r13,%rsi 0x0000555555572200 <+10416>: mov %r14,%rdi 0x0000555555572203 <+10419>: mov $0x2,%r8d 0x0000555555572209 <+10425>: call 0x555555585f20 0x000055555557220e <+10430>: jmp 0x555555571be1 <main+8849> 0x0000555555572213 <+10435>: mov 0x18(%rsp),%rdx 0x0000555555572218 <+10440>: mov $0x2,%ecx 0x000055555557221d <+10445>: mov %r13,%rsi 0x0000555555572220 <+10448>: mov %r14,%rdi 0x0000555555572223 <+10451>: mov $0x1,%r8d 0x0000555555572229 <+10457>: call 0x555555585f20 0x000055555557222e <+10462>: jmp 0x555555571bd4 <main+8836> 0x0000555555572233 <+10467>: xor %edi,%edi 0x0000555555572235 <+10469>: xor %ecx,%ecx 0x0000555555572237 <+10471>: lea 0x1cff3(%rip),%rsi # 0x55555558f231 0x000055555557223e <+10478>: xor %edx,%edx 0x0000555555572240 <+10480>: call *0x23e52(%rip) # 0x555555596098 0x0000555555572246 <+10486>: mov %r14,%rdi 0x0000555555572249 <+10489>: mov %rax,%rsi 0x000055555557224c <+10492>: call 0x55555558b600 0x0000555555572251 <+10497>: jmp 0x555555571c57 <main+8967> 0x0000555555572256 <+10502>: mov 0x18(%rsp),%rdx 0x000055555557225b <+10507>: xor %r8d,%r8d 0x000055555557225e <+10510>: mov $0x2,%ecx 0x0000555555572263 <+10515>: mov %r13,%rsi 0x0000555555572266 <+10518>: mov %r14,%rdi 0x0000555555572269 <+10521>: call 0x555555585f20 0x000055555557226e <+10526>: jmp 0x555555571bc7 <main+8823> 0x0000555555572273 <+10531>: mov 0x18(%rsp),%rdx 0x0000555555572278 <+10536>: xor %r8d,%r8d 0x000055555557227b <+10539>: mov $0x1,%ecx 0x0000555555572280 <+10544>: mov %r13,%rsi 0x0000555555572283 <+10547>: mov %r14,%rdi 0x0000555555572286 <+10550>: call 0x555555585f20 0x000055555557228b <+10555>: jmp 0x555555571bba <main+8810> 0x0000555555572290 <+10560>: mov 0x18(%rsp),%rdx 0x0000555555572295 <+10565>: xor %r8d,%r8d 0x0000555555572298 <+10568>: xor %ecx,%ecx 0x000055555557229a <+10570>: mov %r13,%rsi 0x000055555557229d <+10573>: mov %r14,%rdi 0x00005555555722a0 <+10576>: call 0x555555585f20 0x00005555555722a5 <+10581>: jmp 0x555555571bad <main+8797> 0x00005555555722aa <+10586>: mov %r14,%rdi 0x00005555555722ad <+10589>: call 0x555555585c00 0x00005555555722b2 <+10594>: cmpq $0x0,0x27d16(%rip) # 0x555555599fd0 0x00005555555722ba <+10602>: movb $0x0,0x120(%rsp) 0x00005555555722c2 <+10610>: movb $0x0,0x27cd7(%rip) # 0x555555599fa0 0x00005555555722c9 <+10617>: je 0x55555557268e <main+11582> 0x00005555555722cf <+10623>: lea 0x120(%rsp),%rsi 0x00005555555722d7 <+10631>: lea 0x27ce2(%rip),%rdi # 0x555555599fc0 0x00005555555722de <+10638>: call *0x27cf4(%rip) # 0x555555599fd8 0x00005555555722e4 <+10644>: jmp 0x555555571ba0 <main+8784> 0x00005555555722e9 <+10649>: call *0x242c1(%rip) # 0x5555555965b0 0x00005555555722ef <+10655>: jmp 0x555555571132 <main+6114> 0x00005555555722f4 <+10660>: call *0x242b6(%rip) # 0x5555555965b0 0x00005555555722fa <+10666>: jmp 0x5555555711e4 <main+6292> 0x00005555555722ff <+10671>: cmpb $0x0,0x2851a(%rip) # 0x55555559a820 0x0000555555572306 <+10678>: je 0x5555555725e4 <main+11412> 0x000055555557230c <+10684>: mov 0xf0(%rsp),%rsi 0x0000555555572314 <+10692>: test %rsi,%rsi 0x0000555555572317 <+10695>: je 0x555555572320 <main+10704> 0x0000555555572319 <+10697>: mov 0x88(%rsi),%rsi 0x0000555555572320 <+10704>: mov %r12,%rdi 0x0000555555572323 <+10707>: call *0x2446f(%rip) # 0x555555596798 0x0000555555572329 <+10713>: mov %r14,%rdi 0x000055555557232c <+10716>: mov %rax,%rsi 0x000055555557232f <+10719>: call 0x55555558b600 0x0000555555572334 <+10724>: jmp 0x555555571d5b <main+9227> 0x0000555555572339 <+10729>: call *0x24099(%rip) # 0x5555555963d8 0x000055555557233f <+10735>: lea 0x1cdf2(%rip),%rsi # 0x55555558f138 0x0000555555572346 <+10742>: mov %rax,%rdi 0x0000555555572349 <+10745>: call 0x555555576a00 0x000055555557234e <+10750>: test %bl,%bl 0x0000555555572350 <+10752>: jne 0x555555572622 <main+11474> 0x0000555555572356 <+10758>: mov 0xd8(%rsp),%rax 0x000055555557235e <+10766>: test %rax,%rax 0x0000555555572361 <+10769>: je 0x555555572367 <main+10775> 0x0000555555572363 <+10771>: movb $0x1,0x20(%rax) 0x0000555555572367 <+10775>: mov %r12,%rdi 0x000055555557236a <+10778>: mov $0x1,%r12d 0x0000555555572370 <+10784>: call 0x55555558a1a0 0x0000555555572375 <+10789>: jmp 0x555555571ddf <main+9359> 0x000055555557237a <+10794>: cmpq $0x0,0x28866(%rip) # 0x55555559abe8 0x0000555555572382 <+10802>: je 0x555555572652 <main+11522> 0x0000555555572388 <+10808>: movl $0x0,0x120(%rsp) 0x0000555555572393 <+10819>: call *0x24147(%rip) # 0x5555555964e0 0x0000555555572399 <+10825>: mov 0x28840(%rip),%rbp # 0x55555559abe0 0x00005555555723a0 <+10832>: mov $0x90,%edi 0x00005555555723a5 <+10837>: mov 0x2883c(%rip),%rbx # 0x55555559abe8 0x00005555555723ac <+10844>: mov %rax,0x128(%rsp) 0x00005555555723b4 <+10852>: call *0x244b6(%rip) # 0x555555596870 0x00005555555723ba <+10858>: mov %rbp,%rsi 0x00005555555723bd <+10861>: xor %r8d,%r8d 0x00005555555723c0 <+10864>: mov %rbx,%rdx 0x00005555555723c3 <+10867>: mov %rax,%r12 0x00005555555723c6 <+10870>: lea 0xe8(%rsp),%rbp 0x00005555555723ce <+10878>: mov %rax,%rdi 0x00005555555723d1 <+10881>: lea 0x120(%rsp),%rcx 0x00005555555723d9 <+10889>: call *0x24329(%rip) # 0x555555596708 0x00005555555723df <+10895>: mov %r12,%rsi 0x00005555555723e2 <+10898>: mov %rbp,%rdi 0x00005555555723e5 <+10901>: movq $0x0,0x100(%rsp) 0x00005555555723f1 <+10913>: call 0x55555558b4f0 0x00005555555723f6 <+10918>: lea 0x100(%rsp),%rdi 0x00005555555723fe <+10926>: call 0x55555558b540 0x0000555555572403 <+10931>: cmpl $0x0,0x120(%rsp) 0x000055555557240b <+10939>: je 0x555555571230 <main+6368> 0x0000555555572411 <+10945>: call *0x23fc1(%rip) # 0x5555555963d8 0x0000555555572417 <+10951>: mov 0x128(%rsp),%rsi 0x000055555557241f <+10959>: mov 0x38(%rsp),%rdi 0x0000555555572424 <+10964>: mov %rax,%r12 0x0000555555572427 <+10967>: mov 0x120(%rsp),%edx 0x000055555557242e <+10974>: mov (%rsi),%rax 0x0000555555572431 <+10977>: call *0x20(%rax) 0x0000555555572434 <+10980>: mov %r12,%rdi 0x0000555555572437 <+10983>: mov 0x278(%rsp),%rdx 0x000055555557243f <+10991>: mov 0x270(%rsp),%rsi 0x0000555555572447 <+10999>: call *0x24683(%rip) # 0x555555596ad0 0x000055555557244d <+11005>: mov %rax,%rdi 0x0000555555572450 <+11008>: mov 0x18(%rax),%rax 0x0000555555572454 <+11012>: cmp 0x10(%rdi),%rax 0x0000555555572458 <+11016>: jae 0x555555572694 <main+11588> 0x000055555557245e <+11022>: lea 0x1(%rax),%rdx 0x0000555555572462 <+11026>: mov %rdx,0x18(%rdi) 0x0000555555572466 <+11030>: movb $0xa,(%rax) 0x0000555555572469 <+11033>: mov 0x270(%rsp),%rdi 0x0000555555572471 <+11041>: lea 0x280(%rsp),%rax 0x0000555555572479 <+11049>: cmp %rax,%rdi 0x000055555557247c <+11052>: je 0x555555572490 <main+11072> 0x000055555557247e <+11054>: mov 0x280(%rsp),%rax 0x0000555555572486 <+11062>: lea 0x1(%rax),%rsi 0x000055555557248a <+11066>: call *0x23c00(%rip) # 0x555555596090 0x0000555555572490 <+11072>: mov $0x1,%r12d 0x0000555555572496 <+11078>: jmp 0x555555571e20 <main+9424> 0x000055555557249b <+11083>: movzbl 0x430(%rsp),%eax 0x00005555555724a3 <+11091>: mov %al,(%rdi) 0x00005555555724a5 <+11093>: mov 0x428(%rsp),%rdx 0x00005555555724ad <+11101>: mov 0xf0(%rbx),%rdi 0x00005555555724b4 <+11108>: jmp 0x555555570f08 <main+5560> 0x00005555555724b9 <+11113>: xor %r12d,%r12d 0x00005555555724bc <+11116>: jmp 0x555555571ddf <main+9359> 0x00005555555724c1 <+11121>: mov %rdx,0x88(%rsp) 0x00005555555724c9 <+11129>: mov %r8,0x58(%rsp) 0x00005555555724ce <+11134>: mov %rax,0x80(%rsp) 0x00005555555724d6 <+11142>: call *0x24624(%rip) # 0x555555596b00 0x00005555555724dc <+11148>: mov %r14,%rdi 0x00005555555724df <+11151>: mov %rax,%rsi 0x00005555555724e2 <+11154>: call *0x23b30(%rip) # 0x555555596018 0x00005555555724e8 <+11160>: mov 0x58(%rsp),%r8 0x00005555555724ed <+11165>: mov %r14,%rdi 0x00005555555724f0 <+11168>: mov %r8,%rsi 0x00005555555724f3 <+11171>: call *0x23b1f(%rip) # 0x555555596018 0x00005555555724f9 <+11177>: mov 0x80(%rsp),%r9 0x0000555555572501 <+11185>: mov $0x1,%edi 0x0000555555572506 <+11190>: mov 0x88(%rsp),%rdx 0x000055555557250e <+11198>: lea 0x150(%rsp),%rcx 0x0000555555572516 <+11206>: mov %r9,%rsi 0x0000555555572519 <+11209>: call *0x249f1(%rip) # 0x555555596f10 0x000055555557251f <+11215>: mov %r14,%rdi 0x0000555555572522 <+11218>: mov %rax,%rsi 0x0000555555572525 <+11221>: call *0x23aed(%rip) # 0x555555596018 0x000055555557252b <+11227>: jmp 0x55555557143b <main+6891> 0x0000555555572530 <+11232>: mov $0xa,%esi 0x0000555555572535 <+11237>: call *0x23e6d(%rip) # 0x5555555963a8 0x000055555557253b <+11243>: jmp 0x55555557206f <main+10015> 0x0000555555572540 <+11248>: test %rdx,%rdx 0x0000555555572543 <+11251>: je 0x555555572565 <main+11285> 0x0000555555572545 <+11253>: mov %rdx,0x38(%rsp) 0x000055555557254a <+11258>: mov 0x100(%rsp),%rsi 0x0000555555572552 <+11266>: mov 0x120(%rsp),%rdi 0x000055555557255a <+11274>: call *0x23b80(%rip) # 0x5555555960e0 0x0000555555572560 <+11280>: mov 0x38(%rsp),%rdx 0x0000555555572565 <+11285>: mov %rdx,0x128(%rsp) 0x000055555557256d <+11293>: jmp 0x55555557214a <main+10234> 0x0000555555572572 <+11298>: mov $0x1,%edi 0x0000555555572577 <+11303>: call *0x24803(%rip) # 0x555555596d80 0x000055555557257d <+11309>: mov %r14,%rdi 0x0000555555572580 <+11312>: mov %rax,%rsi 0x0000555555572583 <+11315>: call 0x55555558b600 0x0000555555572588 <+11320>: jmp 0x555555571c4c <main+8956> 0x000055555557258d <+11325>: mov 0x26cac(%rip),%rdi # 0x555555599240 0x0000555555572594 <+11332>: lea 0x150(%rsp),%rdx 0x000055555557259c <+11340>: addr32 call 0x55555558add0 <_Z19exportDebugifyStatsN4llvm9StringRefERKNS_9MapVectorIS0_18DebugifyStatisticsNS_8DenseMapIS0_jNS_12DenseMapInfoIS0_EENS_6detail12DenseMapPairIS0_jEEEESt6vectorISt4pairIS0_S2_ESaISC_EEEE> 0x00005555555725a2 <+11346>: jmp 0x555555571d98 <main+9288> 0x00005555555725a7 <+11351>: mov %rdx,0x38(%rsp) 0x00005555555725ac <+11356>: mov $0x1,%ecx 0x00005555555725b1 <+11361>: mov 0x28(%rsp),%rsi 0x00005555555725b6 <+11366>: lea 0x120(%rsp),%rdi 0x00005555555725be <+11374>: movq $0x0,0x128(%rsp) 0x00005555555725ca <+11386>: call *0x243b0(%rip) # 0x555555596980 0x00005555555725d0 <+11392>: mov 0x108(%rsp),%rdx 0x00005555555725d8 <+11400>: mov 0x38(%rsp),%r8 0x00005555555725dd <+11405>: xor %ecx,%ecx 0x00005555555725df <+11407>: jmp 0x555555572110 <main+10176> 0x00005555555725e4 <+11412>: mov %r12,%rdi 0x00005555555725e7 <+11415>: movzbl 0x27132(%rip),%ecx # 0x555555599720 0x00005555555725ee <+11422>: movzbl 0x271eb(%rip),%edx # 0x5555555997e0 0x00005555555725f5 <+11429>: movzbl 0x269c4(%rip),%esi # 0x555555598fc0 0x00005555555725fc <+11436>: call *0x23e86(%rip) # 0x555555596488 0x0000555555572602 <+11442>: mov %r14,%rdi 0x0000555555572605 <+11445>: mov %rax,%rsi 0x0000555555572608 <+11448>: call 0x55555558b600 0x000055555557260d <+11453>: jmp 0x555555571d5b <main+9227> 0x0000555555572612 <+11458>: mov $0xa,%esi 0x0000555555572617 <+11463>: call *0x23d8b(%rip) # 0x5555555963a8 0x000055555557261d <+11469>: jmp 0x555555570a3b <main+4331> 0x0000555555572622 <+11474>: mov 0xe8(%rsp),%rax 0x000055555557262a <+11482>: mov 0x88(%rax),%rdi 0x0000555555572631 <+11489>: mov 0x38(%rbp),%rax 0x0000555555572635 <+11493>: mov 0x8(%rax),%rdx 0x0000555555572639 <+11497>: mov (%rax),%rsi 0x000055555557263c <+11500>: call 0x5555555769a0 0x0000555555572641 <+11505>: mov 0xe8(%rsp),%rax 0x0000555555572649 <+11513>: movb $0x1,0x20(%rax) 0x000055555557264d <+11517>: jmp 0x555555572356 <main+10758> 0x0000555555572652 <+11522>: lea 0x1a495(%rip),%rsi # 0x55555558caee 0x0000555555572659 <+11529>: lea 0x28500(%rip),%rdi # 0x55555559ab60 0x0000555555572660 <+11536>: call 0x555555587f10 0x0000555555572665 <+11541>: jmp 0x555555572388 <main+10808> 0x000055555557266a <+11546>: mov 0xe8(%rsp),%rax 0x0000555555572672 <+11554>: mov 0x88(%rax),%rdi 0x0000555555572679 <+11561>: mov 0x38(%rbp),%rax 0x000055555557267d <+11565>: mov 0x8(%rax),%rdx 0x0000555555572681 <+11569>: mov (%rax),%rsi 0x0000555555572684 <+11572>: call 0x5555555769a0 0x0000555555572689 <+11577>: jmp 0x5555555721a3 <main+10323> 0x000055555557268e <+11582>: call *0x24054(%rip) # 0x5555555966e8 0x0000555555572694 <+11588>: mov $0xa,%esi 0x0000555555572699 <+11593>: call *0x23d09(%rip) # 0x5555555963a8 0x000055555557269f <+11599>: jmp 0x555555572469 <main+11033> 0x00005555555726a4 <+11604>: call *0x23b3e(%rip) # 0x5555555961e8 0x00005555555726aa <+11610>: lea 0x19b47(%rip),%rdi # 0x55555558c1f8 0x00005555555726b1 <+11617>: call *0x24129(%rip) # 0x5555555967e0 0x00005555555726b7 <+11623>: mov $0x1,%esi 0x00005555555726bc <+11628>: lea 0x1ca45(%rip),%rdi # 0x55555558f108 0x00005555555726c3 <+11635>: call *0x2490f(%rip) # 0x555555596fd8 0x00005555555726c9 <+11641>: mov $0x1,%esi 0x00005555555726ce <+11646>: lea 0x1c9fb(%rip),%rdi # 0x55555558f0d0 0x00005555555726d5 <+11653>: call *0x248fd(%rip) # 0x555555596fd8 0x00005555555726db <+11659>: mov %bl,0x60(%rsp) 0x00005555555726df <+11663>: jmp 0x555555571ed4 <main+9604> End of assembler dump.
#ifndef XOROSHIRO_HPP_INCLUDED #define XOROSHIRO_HPP_INCLUDED 1 /* * A C++ implementation of a family of Xoroshiro generators. * * See: * https://en.wikipedia.org/wiki/Xoroshiro128%2B * http://xoroshiro.di.unimi.it/xoroshiro128plus.c * * Based on the design and public domain implementation of * Xoroshiro128+ by written in 2016 by David Blackman and Sebastiano * Vigna. Also updated for the 2018 V1.0 versions of Xoroshiro. * * Xoroshiro128+ fails PractRand and TestU01 because of weak low order * bits. Blackman and Vigna recommend users take care to avoid * relying on the low bits. See their original source for details. * My test results are included below. * * Xoroshiro128+ is a variant on the ideas given by George Marsaglia * for XorShift, and as such it is possible to use the same * binary-matrix techniques to create the necessary magic constants to * define other members of the Xoroshiro family at different bit * sizes. In particular, Xoroshiro64+ may be sufficient for some * applications and will run better on some 32-bit machines. * * The MIT License (MIT) * * Copyright (c) 2017-19 Melissa E. O'Neill * * 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. */ #include <cstdint> namespace xoroshiro_detail { template <typename itype, typename rtype, unsigned int a, unsigned int b, unsigned int c> class xoroshiro { protected: itype s0_, s1_; static constexpr unsigned int ITYPE_BITS = 8*sizeof(itype); static constexpr unsigned int RTYPE_BITS = 8*sizeof(rtype); static inline itype rotl(const itype x, int k) { return (x << k) | (x >> (ITYPE_BITS - k)); } public: using result_type = rtype; static constexpr result_type min() { return 0; } static constexpr result_type max() { return ~ result_type(0); } xoroshiro(itype s0 = itype(0xc1f651c67c62c6e0), itype s1 = itype(0x30d89576f866ac9f)) // Easter-egg seed value for Xoroshiro128+ to remind users that // they should seed their PRNGs properly. : s0_(s0), s1_((s0 || s1) ? s1 : 1) { // Nothing (else) to do. } void advance() { s1_ ^= s0_; s0_ = rotl(s0_, a) ^ s1_ ^ (s1_ << b); s1_ = rotl(s1_, c); } bool operator==(const xoroshiro& rhs) { return (s0_ == rhs.s0_) && (s1_ == rhs.s1_); } bool operator!=(const xoroshiro& rhs) { return !operator==(rhs); } // Not (yet) implemented: // - arbitrary jumpahead (doable, but annoying to write). // - I/O // - Seeding from a seed_seq. }; template <typename itype, typename rtype, unsigned int a, unsigned int b, unsigned int c> class xoroshiro_plus : public xoroshiro<itype,rtype,a,b,c> { private: using base = xoroshiro<itype,rtype,a,b,c>; public: using base::base; rtype operator()() { const itype result = base::s0_ + base::s1_; base::advance(); return result >> (base::ITYPE_BITS - base::RTYPE_BITS); } }; template <typename itype, typename rtype, unsigned int a, unsigned int b, unsigned int c, itype mult> class xoroshiro_star : public xoroshiro<itype,rtype,a,b,c> { private: using base = xoroshiro<itype,rtype,a,b,c>; public: using base::base; rtype operator()() { const itype result_star = base::s0_ * mult; base::advance(); return result_star >> (base::ITYPE_BITS - base::RTYPE_BITS); } }; template <typename itype, typename rtype, unsigned int a, unsigned int b, unsigned int c, itype mult1, unsigned int orot, itype mult2> class xoroshiro_starstar : public xoroshiro<itype,rtype,a,b,c> { private: using base = xoroshiro<itype,rtype,a,b,c>; public: using base::base; rtype operator()() { const itype result_ss = base::rotl(base::s0_ * mult1, orot) * mult2; base::advance(); return result_ss >> (base::ITYPE_BITS - base::RTYPE_BITS); } }; } // namespace xoroshiro_detail // 128 // // This is the generator recommended by Vigna and Blackman. It fails // PractRand and TestU01 although it can be considered as passing if // the failures are ignored. (??!?!) // // TestU01 linear complexity results: // //| Testing Xoroshiro128+ (Vigna's Code) [Low bits] [Reversed]: //| - seed_data[2] = { 0xda1ff5a1e44ba0f8, 0x511a1a4da9858f9a} //| *********************************************************** //| Xoroshiro128+ (Vigna's Code) [Low bits] [Reversed] //| scomp_LinearComp test: //| ----------------------------------------------- //| N = 1, n = 250, r = 0, s = 1 //| ----------------------------------------------- //| Number of degrees of freedom : 1 //| Chi2 statistic for size of jumps : 2.32 //| p-value of test : 0.13 //| ----------------------------------------------- //| Normal statistic for number of jumps : -0.15 //| p-value of test : 0.56 //| ----------------------------------------------- //| CPU time used : 00:00:00.00 //| *********************************************************** //| Xoroshiro128+ (Vigna's Code) [Low bits] [Reversed] //| scomp_LinearComp test: //| ----------------------------------------------- //| N = 1, n = 500, r = 0, s = 1 //| ----------------------------------------------- //| Number of degrees of freedom : 2 //| Chi2 statistic for size of jumps : 1.97 //| p-value of test : 0.37 //| ----------------------------------------------- //| Normal statistic for number of jumps : -7.27 //| p-value of test : 1 - 1.9e-13 ***** //| ----------------------------------------------- //| CPU time used : 00:00:00.00 //| *********************************************************** //| Xoroshiro128+ (Vigna's Code) [Low bits] [Reversed] //| scomp_LinearComp test: //| ----------------------------------------------- //| N = 1, n = 1000, r = 0, s = 1 //| ----------------------------------------------- //| Number of degrees of freedom : 3 //| Chi2 statistic for size of jumps : 4.33 //| p-value of test : 0.23 //| ----------------------------------------------- //| Normal statistic for number of jumps : -17.31 //| p-value of test : 1 - eps1 ***** //| ----------------------------------------------- //| CPU time used : 00:00:00.00 //| *********************************************************** // // TestU01 Crush Results: //| ========= Summary results of Crush ========= //| //| Version: TestU01 1.2.3 //| Generator: Xoroshiro128+ (Vigna's Code) [Low bits] [Reversed] //| Number of statistics: 144 //| Total CPU time: 00:39:57.80 //| The following tests gave p-values outside [0.001, 0.9990]: //| (eps means a value < 1.0e-300): //| (eps1 means a value < 1.0e-15): //| //| Test p-value //| ---------------------------------------------- //| 71 LinearComp, r = 0 1 - eps1 //| ---------------------------------------------- //| All other tests were passed // // TestU01 BigCrush Results: // //| ========= Summary results of BigCrush ========= //| //| Version: TestU01 1.2.3 //| Generator: Xoroshiro128+ (Vigna's Code) [Low bits] [Reversed] //| Number of statistics: 160 //| Total CPU time: 04:14:51.79 //| The following tests gave p-values outside [0.001, 0.9990]: //| (eps means a value < 1.0e-300): //| (eps1 means a value < 1.0e-15): //| //| Test p-value //| ---------------------------------------------- //| 68 MatrixRank, L=1000, r=0 eps //| 71 MatrixRank, L=5000 eps //| 80 LinearComp, r = 0 1 - eps1 //| ---------------------------------------------- //| All other tests were passed // // PractRand Results (standard: RNG_test stdin64 -tlmin 23): // //| RNG_test using PractRand version 0.93 //| RNG = RNG_stdin64, seed = 0x7ddef6ce //| test set = normal, folding = standard (64 bit) //| //| rng=RNG_stdin64, seed=0x7ddef6ce //| length= 8 megabytes (2^23 bytes), time= 0.2 seconds //| no anomalies in 106 test result(s) //| //| rng=RNG_stdin64, seed=0x7ddef6ce //| length= 16 megabytes (2^24 bytes), time= 1.2 seconds //| no anomalies in 116 test result(s) //| //| rng=RNG_stdin64, seed=0x7ddef6ce //| length= 32 megabytes (2^25 bytes), time= 2.3 seconds //| Test Name Raw Processed Evaluation //| [Low1/64]BRank(12):256(1) R= +2650 p~= 9.8e-799 FAIL !!!!!!! //| ...and 126 test result(s) without anomalies // // PractRand (extended: RNG_test stdin64 -tlmaxonly -te 1 -tf 2) //| RNG = RNG_stdin64, seed = 0x88ab2def //| test set = expanded, folding = extra //| //| rng=RNG_stdin64, seed=0x88ab2def //| length= 32 megabytes (2^25 bytes), time= 2.3 seconds //| Test Name Raw Processed Evaluation //| [Low1/16]BRank(18):768(1) R= +1272 p~= 5.4e-384 FAIL !!!!!!! //| [Low1/32]BRank(18):384(1) R= +1272 p~= 5.4e-384 FAIL !!!!!!! //| [Low1/32]BRank(18):512(1) R= +2650 p~= 9.8e-799 FAIL !!!!!!! //| [Low1/64]BRank(18):256(2) R= +3748 p~= 3e-1129 FAIL !!!!!!!! //| [Low1/64]BRank(18):384(1) R= +5405 p~= 3e-1628 FAIL !!!!!!!! //| [Low4/64]BRank(18):768(1) R= +1272 p~= 5.4e-384 FAIL !!!!!!! //| ...and 790 test result(s) without anomalies //: //: //| rng=RNG_stdin64, seed=0x88ab2def //| length= 8 terabytes (2^43 bytes), time= 519110 seconds //| Test Name Raw Processed Evaluation //| BRank(18):12K(8) R= +3598 p~= 2e-2310 FAIL !!!!!!!! //| BRank(18):16K(32) R=+14990 p~= 0 FAIL !!!!!!!! //| BRank(18):24K(8) R=+15289 p~= 4e-9814 FAIL !!!!!!!! //| BRank(18):32K(16) R=+32644 p~= 0 FAIL !!!!!!!! //| BRank(18):48K(4) R=+27344 p~= 0 FAIL !!!!!!!! //| BRank(18):64K(11) R=+63622 p~= 0 FAIL !!!!!!!! //| DC6-5x4Bytes-1 R= +6.5 p = 3.4e-4 unusual //| [Low1/8]BRank(18):1536(4) R= +2544 p~= 4e-1354 FAIL !!!!!!!! //| [Low1/8]BRank(18):2K(8) R= +7495 p~= 1e-4811 FAIL !!!!!!!! //| [Low1/8]BRank(18):3K(2) R= +7644 p~= 3e-2302 FAIL !!!!!!!! //| [Low1/8]BRank(18):4K(8) R=+23082 p~= 0 FAIL !!!!!!!! //| [Low1/8]BRank(18):6K(2) R=+19335 p~= 2e-5821 FAIL !!!!!!!! //| [Low1/8]BRank(18):8K(4) R=+38366 p~= 0 FAIL !!!!!!!! //| [Low1/8]BRank(18):12K(1) R=+30205 p~= 1e-9093 FAIL !!!!!!!! //| [Low1/8]BRank(18):16K(4) R=+82453 p~= 0 FAIL !!!!!!!! //| [Low1/8]BRank(18):24K(1) R=+63271 p~= 0 FAIL !!!!!!!! //| [Low1/8]BRank(18):32K(2) R=+120653 p~= 0 FAIL !!!!!!!! //| [Low1/8]BRank(18):48K(1) R=+129402 p~= 0 FAIL !!!!!!!! //| [Low1/8]BRank(18):64K(1) R=+173490 p~= 0 FAIL !!!!!!!! //| [Low1/16]BRank(18):768(4) R= +2544 p~= 4e-1354 FAIL !!!!!!!! //| [Low1/16]BRank(18):1K(8) R= +7495 p~= 1e-4811 FAIL !!!!!!!! //| [Low1/16]BRank(18):1536(2) R= +7644 p~= 3e-2302 FAIL !!!!!!!! //| [Low1/16]BRank(18):2K(8) R=+23082 p~= 0 FAIL !!!!!!!! //| [Low1/16]BRank(18):3K(2) R=+19335 p~= 2e-5821 FAIL !!!!!!!! //| [Low1/16]BRank(18):4K(4) R=+38366 p~= 0 FAIL !!!!!!!! //| [Low1/16]BRank(18):6K(1) R=+30205 p~= 1e-9093 FAIL !!!!!!!! //| [Low1/16]BRank(18):8K(4) R=+82453 p~= 0 FAIL !!!!!!!! //| [Low1/16]BRank(18):12K(1) R=+63271 p~= 0 FAIL !!!!!!!! //| [Low1/16]BRank(18):16K(2) R=+120653 p~= 0 FAIL !!!!!!!! //| [Low1/16]BRank(18):24K(1) R=+129402 p~= 0 FAIL !!!!!!!! //| [Low1/16]BRank(18):32K(2) R=+245352 p~= 0 FAIL !!!!!!!! //| [Low1/16]BRank(18):48K(1) R=+261665 p~= 0 FAIL !!!!!!!! //| [Low1/32]BRank(18):384(4) R= +2544 p~= 4e-1354 FAIL !!!!!!!! //| [Low1/32]BRank(18):512(8) R= +7495 p~= 1e-4811 FAIL !!!!!!!! //| [Low1/32]BRank(18):768(4) R=+10811 p~= 1e-5750 FAIL !!!!!!!! //| [Low1/32]BRank(18):1K(8) R=+23082 p~= 0 FAIL !!!!!!!! //| [Low1/32]BRank(18):1536(2) R=+19335 p~= 2e-5821 FAIL !!!!!!!! //| [Low1/32]BRank(18):2K(4) R=+38366 p~= 0 FAIL !!!!!!!! //| [Low1/32]BRank(18):3K(2) R=+42716 p~= 0 FAIL !!!!!!!! //| [Low1/32]BRank(18):4K(4) R=+82453 p~= 0 FAIL !!!!!!!! //| [Low1/32]BRank(18):6K(1) R=+63271 p~= 0 FAIL !!!!!!!! //| [Low1/32]BRank(18):8K(2) R=+120653 p~= 0 FAIL !!!!!!!! //| [Low1/32]BRank(18):12K(1) R=+129402 p~= 0 FAIL !!!!!!!! //| [Low1/32]BRank(18):16K(2) R=+245352 p~= 0 FAIL !!!!!!!! //| [Low1/32]BRank(18):24K(1) R=+261665 p~= 0 FAIL !!!!!!!! //| [Low1/32]BRank(18):32K(1) R=+349841 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):256(16) R=+10600 p~= 3e-7802 FAIL !!!!!!!! //| [Low1/64]BRank(18):384(4) R=+10811 p~= 1e-5750 FAIL !!!!!!!! //| [Low1/64]BRank(18):512(8) R=+23082 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):768(4) R=+27344 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):1K(8) R=+54257 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):1536(2) R=+42716 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):2K(4) R=+82453 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):3K(2) R=+89478 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):4K(4) R=+170629 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):6K(1) R=+129402 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):8K(2) R=+245352 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):12K(1) R=+261665 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):16K(2) R=+494750 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):24K(1) R=+526192 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):32K(1) R=+702543 p~= 0 FAIL !!!!!!!! //| [Low4/16]BRank(18):3K(4) R= +2544 p~= 4e-1354 FAIL !!!!!!!! //| [Low4/16]BRank(18):4K(16) R=+10600 p~= 3e-7802 FAIL !!!!!!!! //| [Low4/16]BRank(18):6K(4) R=+10811 p~= 1e-5750 FAIL !!!!!!!! //| [Low4/16]BRank(18):8K(8) R=+23082 p~= 0 FAIL !!!!!!!! //| [Low4/16]BRank(18):12K(2) R=+19335 p~= 2e-5821 FAIL !!!!!!!! //| [Low4/16]BRank(18):16K(8) R=+54257 p~= 0 FAIL !!!!!!!! //| [Low4/16]BRank(18):24K(2) R=+42716 p~= 0 FAIL !!!!!!!! //| [Low4/16]BRank(18):32K(4) R=+82453 p~= 0 FAIL !!!!!!!! //| [Low4/16]BRank(18):48K(1) R=+63271 p~= 0 FAIL !!!!!!!! //| [Low4/16]BRank(18):64K(2) R=+120653 p~= 0 FAIL !!!!!!!! //| [Low4/32]BRank(18):1536(4) R= +2544 p~= 4e-1354 FAIL !!!!!!!! //| [Low4/32]BRank(18):2K(8) R= +7495 p~= 1e-4811 FAIL !!!!!!!! //| [Low4/32]BRank(18):3K(2) R= +7644 p~= 3e-2302 FAIL !!!!!!!! //| [Low4/32]BRank(18):4K(8) R=+23082 p~= 0 FAIL !!!!!!!! //| [Low4/32]BRank(18):6K(2) R=+19335 p~= 2e-5821 FAIL !!!!!!!! //| [Low4/32]BRank(18):8K(4) R=+38366 p~= 0 FAIL !!!!!!!! //| [Low4/32]BRank(18):12K(1) R=+30205 p~= 1e-9093 FAIL !!!!!!!! //| [Low4/32]BRank(18):16K(4) R=+82453 p~= 0 FAIL !!!!!!!! //| [Low4/32]BRank(18):24K(1) R=+63271 p~= 0 FAIL !!!!!!!! //| [Low4/32]BRank(18):32K(2) R=+120653 p~= 0 FAIL !!!!!!!! //| [Low4/32]BRank(18):48K(1) R=+129402 p~= 0 FAIL !!!!!!!! //| [Low4/32]BRank(18):64K(1) R=+174868 p~= 0 FAIL !!!!!!!! //| [Low4/64]BRank(18):768(4) R= +2544 p~= 4e-1354 FAIL !!!!!!!! //| [Low4/64]BRank(18):1K(8) R= +7495 p~= 1e-4811 FAIL !!!!!!!! //| [Low4/64]BRank(18):1536(2) R= +7644 p~= 3e-2302 FAIL !!!!!!!! //| [Low4/64]BRank(18):2K(8) R=+23082 p~= 0 FAIL !!!!!!!! //| [Low4/64]BRank(18):3K(2) R=+19335 p~= 2e-5821 FAIL !!!!!!!! //| [Low4/64]BRank(18):4K(4) R=+38366 p~= 0 FAIL !!!!!!!! //| [Low4/64]BRank(18):6K(1) R=+30205 p~= 1e-9093 FAIL !!!!!!!! //| [Low4/64]BRank(18):8K(4) R=+82453 p~= 0 FAIL !!!!!!!! //| [Low4/64]BRank(18):12K(1) R=+63271 p~= 0 FAIL !!!!!!!! //| [Low4/64]BRank(18):16K(2) R=+120653 p~= 0 FAIL !!!!!!!! //| [Low4/64]BRank(18):24K(1) R=+129402 p~= 0 FAIL !!!!!!!! //| [Low4/64]BRank(18):32K(2) R=+247300 p~= 0 FAIL !!!!!!!! //| [Low4/64]BRank(18):48K(1) R=+351219 p~= 0 FAIL !!!!!!!! //| [Low8/32]BRank(18):3K(4) R= +2544 p~= 4e-1354 FAIL !!!!!!!! //| [Low8/32]BRank(18):4K(16) R=+10600 p~= 3e-7802 FAIL !!!!!!!! //| [Low8/32]BRank(18):6K(4) R=+10811 p~= 1e-5750 FAIL !!!!!!!! //| [Low8/32]BRank(18):8K(8) R=+23082 p~= 0 FAIL !!!!!!!! //| [Low8/32]BRank(18):12K(2) R=+19335 p~= 2e-5821 FAIL !!!!!!!! //| [Low8/32]BRank(18):16K(8) R=+54257 p~= 0 FAIL !!!!!!!! //| [Low8/32]BRank(18):24K(2) R=+42716 p~= 0 FAIL !!!!!!!! //| [Low8/32]BRank(18):32K(4) R=+82453 p~= 0 FAIL !!!!!!!! //| [Low8/32]BRank(18):48K(1) R=+63271 p~= 0 FAIL !!!!!!!! //| [Low8/32]BRank(18):64K(2) R=+120653 p~= 0 FAIL !!!!!!!! //| [Low8/64]BRank(18):1536(4) R= +2544 p~= 4e-1354 FAIL !!!!!!!! //| [Low8/64]BRank(18):2K(8) R= +7495 p~= 1e-4811 FAIL !!!!!!!! //| [Low8/64]BRank(18):3K(2) R= +7644 p~= 3e-2302 FAIL !!!!!!!! //| [Low8/64]BRank(18):4K(8) R=+23082 p~= 0 FAIL !!!!!!!! //| [Low8/64]BRank(18):6K(2) R=+19335 p~= 2e-5821 FAIL !!!!!!!! //| [Low8/64]BRank(18):8K(4) R=+38366 p~= 0 FAIL !!!!!!!! //| [Low8/64]BRank(18):12K(1) R=+30205 p~= 1e-9093 FAIL !!!!!!!! //| [Low8/64]BRank(18):16K(4) R=+82453 p~= 0 FAIL !!!!!!!! //| [Low8/64]BRank(18):24K(1) R=+63271 p~= 0 FAIL !!!!!!!! //| [Low8/64]BRank(18):32K(2) R=+120653 p~= 0 FAIL !!!!!!!! //| [Low8/64]BRank(18):48K(1) R=+129402 p~= 0 FAIL !!!!!!!! //| [Low8/64]BRank(18):64K(1) R=+174868 p~= 0 FAIL !!!!!!!! //| ...and 1698 test result(s) without anomalies //| //| rng=RNG_stdin64, seed=0x88ab2def //| length= 16 terabytes (2^44 bytes), time= 1067251 seconds //| Test Name Raw Processed Evaluation //| BRank(18):12K(16) R= +5089 p~= 4e-3746 FAIL !!!!!!!! //| BRank(18):16K(64) R=+21199 p~= 0 FAIL !!!!!!!! //| BRank(18):24K(16) R=+21622 p~= 0 FAIL !!!!!!!! //| BRank(18):32K(32) R=+46165 p~= 0 FAIL !!!!!!!! //| BRank(18):48K(8) R=+38670 p~= 0 FAIL !!!!!!!! //| BRank(18):64K(22) R=+89975 p~= 0 FAIL !!!!!!!! //| DC6-5x4Bytes-1 R= +12.4 p = 9.8e-8 very suspicious //| [Low1/8]BRank(18):1536(8) R= +3598 p~= 2e-2310 FAIL !!!!!!!! //| [Low1/8]BRank(18):2K(16) R=+10600 p~= 3e-7802 FAIL !!!!!!!! //| [Low1/8]BRank(18):3K(4) R=+10811 p~= 1e-5750 FAIL !!!!!!!! //| [Low1/8]BRank(18):4K(16) R=+32644 p~= 0 FAIL !!!!!!!! //| [Low1/8]BRank(18):6K(4) R=+27344 p~= 0 FAIL !!!!!!!! //| [Low1/8]BRank(18):8K(8) R=+54257 p~= 0 FAIL !!!!!!!! //| [Low1/8]BRank(18):12K(2) R=+42716 p~= 0 FAIL !!!!!!!! //| [Low1/8]BRank(18):16K(8) R=+116607 p~= 0 FAIL !!!!!!!! //| [Low1/8]BRank(18):24K(2) R=+89478 p~= 0 FAIL !!!!!!!! //| [Low1/8]BRank(18):32K(4) R=+170629 p~= 0 FAIL !!!!!!!! //| [Low1/8]BRank(18):48K(1) R=+129402 p~= 0 FAIL !!!!!!!! //| [Low1/8]BRank(18):64K(2) R=+245352 p~= 0 FAIL !!!!!!!! //| [Low1/16]BRank(18):768(4) R= +2544 p~= 4e-1354 FAIL !!!!!!!! //| [Low1/16]BRank(18):1K(16) R=+10600 p~= 3e-7802 FAIL !!!!!!!! //| [Low1/16]BRank(18):1536(4) R=+10811 p~= 1e-5750 FAIL !!!!!!!! //| [Low1/16]BRank(18):2K(8) R=+23082 p~= 0 FAIL !!!!!!!! //| [Low1/16]BRank(18):3K(2) R=+19335 p~= 2e-5821 FAIL !!!!!!!! //| [Low1/16]BRank(18):4K(8) R=+54257 p~= 0 FAIL !!!!!!!! //| [Low1/16]BRank(18):6K(2) R=+42716 p~= 0 FAIL !!!!!!!! //| [Low1/16]BRank(18):8K(4) R=+82453 p~= 0 FAIL !!!!!!!! //| [Low1/16]BRank(18):12K(1) R=+63271 p~= 0 FAIL !!!!!!!! //| [Low1/16]BRank(18):16K(4) R=+170629 p~= 0 FAIL !!!!!!!! //| [Low1/16]BRank(18):24K(1) R=+129402 p~= 0 FAIL !!!!!!!! //| [Low1/16]BRank(18):32K(2) R=+245352 p~= 0 FAIL !!!!!!!! //| [Low1/16]BRank(18):48K(1) R=+261665 p~= 0 FAIL !!!!!!!! //| [Low1/16]BRank(18):64K(1) R=+349841 p~= 0 FAIL !!!!!!!! //| [Low1/32]BRank(18):384(4) R= +2544 p~= 4e-1354 FAIL !!!!!!!! //| [Low1/32]BRank(18):512(16) R=+10600 p~= 3e-7802 FAIL !!!!!!!! //| [Low1/32]BRank(18):768(4) R=+10811 p~= 1e-5750 FAIL !!!!!!!! //| [Low1/32]BRank(18):1K(8) R=+23082 p~= 0 FAIL !!!!!!!! //| [Low1/32]BRank(18):1536(2) R=+19335 p~= 2e-5821 FAIL !!!!!!!! //| [Low1/32]BRank(18):2K(8) R=+54257 p~= 0 FAIL !!!!!!!! //| [Low1/32]BRank(18):3K(2) R=+42716 p~= 0 FAIL !!!!!!!! //| [Low1/32]BRank(18):4K(4) R=+82453 p~= 0 FAIL !!!!!!!! //| [Low1/32]BRank(18):6K(1) R=+63271 p~= 0 FAIL !!!!!!!! //| [Low1/32]BRank(18):8K(4) R=+170629 p~= 0 FAIL !!!!!!!! //| [Low1/32]BRank(18):12K(1) R=+129402 p~= 0 FAIL !!!!!!!! //| [Low1/32]BRank(18):16K(2) R=+245352 p~= 0 FAIL !!!!!!!! //| [Low1/32]BRank(18):24K(1) R=+261665 p~= 0 FAIL !!!!!!!! //| [Low1/32]BRank(18):32K(2) R=+494750 p~= 0 FAIL !!!!!!!! //| [Low1/32]BRank(18):48K(1) R=+526192 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):256(16) R=+10600 p~= 3e-7802 FAIL !!!!!!!! //| [Low1/64]BRank(18):384(4) R=+10811 p~= 1e-5750 FAIL !!!!!!!! //| [Low1/64]BRank(18):512(8) R=+23082 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):768(4) R=+27344 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):1K(8) R=+54257 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):1536(2) R=+42716 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):2K(4) R=+82453 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):3K(2) R=+89478 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):4K(4) R=+170629 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):6K(1) R=+129402 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):8K(2) R=+245352 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):12K(1) R=+261665 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):16K(2) R=+494750 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):24K(1) R=+526192 p~= 0 FAIL !!!!!!!! //| [Low1/64]BRank(18):32K(1) R=+702543 p~= 0 FAIL !!!!!!!! //| [Low4/16]BRank(18):3K(8) R= +3598 p~= 2e-2310 FAIL !!!!!!!! //| [Low4/16]BRank(18):4K(32) R=+14990 p~= 0 FAIL !!!!!!!! //| [Low4/16]BRank(18):6K(8) R=+15289 p~= 4e-9814 FAIL !!!!!!!! //| [Low4/16]BRank(18):8K(16) R=+32644 p~= 0 FAIL !!!!!!!! //| [Low4/16]BRank(18):12K(4) R=+27344 p~= 0 FAIL !!!!!!!! //| [Low4/16]BRank(18):16K(16) R=+76731 p~= 0 FAIL !!!!!!!! //| [Low4/16]BRank(18):24K(4) R=+60410 p~= 0 FAIL !!!!!!!! //| [Low4/16]BRank(18):32K(8) R=+116607 p~= 0 FAIL !!!!!!!! //| [Low4/16]BRank(18):48K(2) R=+89478 p~= 0 FAIL !!!!!!!! //| [Low4/16]BRank(18):64K(5) R=+190769 p~= 0 FAIL !!!!!!!! //| [Low4/32]BRank(18):1536(8) R= +3598 p~= 2e-2310 FAIL !!!!!!!! //| [Low4/32]BRank(18):2K(16) R=+10600 p~= 3e-7802 FAIL !!!!!!!! //| [Low4/32]BRank(18):3K(4) R=+10811 p~= 1e-5750 FAIL !!!!!!!! //| [Low4/32]BRank(18):4K(16) R=+32644 p~= 0 FAIL !!!!!!!! //| [Low4/32]BRank(18):6K(4) R=+27344 p~= 0 FAIL !!!!!!!! //| [Low4/32]BRank(18):8K(8) R=+54257 p~= 0 FAIL !!!!!!!! //| [Low4/32]BRank(18):12K(2) R=+42716 p~= 0 FAIL !!!!!!!! //| [Low4/32]BRank(18):16K(8) R=+116607 p~= 0 FAIL !!!!!!!! //| [Low4/32]BRank(18):24K(2) R=+89478 p~= 0 FAIL !!!!!!!! //| [Low4/32]BRank(18):32K(4) R=+170629 p~= 0 FAIL !!!!!!!! //| [Low4/32]BRank(18):48K(1) R=+129402 p~= 0 FAIL !!!!!!!! //| [Low4/32]BRank(18):64K(2) R=+247300 p~= 0 FAIL !!!!!!!! //| [Low4/64]BRank(18):768(4) R= +2544 p~= 4e-1354 FAIL !!!!!!!! //| [Low4/64]BRank(18):1K(16) R=+10600 p~= 3e-7802 FAIL !!!!!!!! //| [Low4/64]BRank(18):1536(4) R=+10811 p~= 1e-5750 FAIL !!!!!!!! //| [Low4/64]BRank(18):2K(8) R=+23082 p~= 0 FAIL !!!!!!!! //| [Low4/64]BRank(18):3K(2) R=+19335 p~= 2e-5821 FAIL !!!!!!!! //| [Low4/64]BRank(18):4K(8) R=+54257 p~= 0 FAIL !!!!!!!! //| [Low4/64]BRank(18):6K(2) R=+42716 p~= 0 FAIL !!!!!!!! //| [Low4/64]BRank(18):8K(4) R=+82453 p~= 0 FAIL !!!!!!!! //| [Low4/64]BRank(18):12K(1) R=+63271 p~= 0 FAIL !!!!!!!! //| [Low4/64]BRank(18):16K(4) R=+170629 p~= 0 FAIL !!!!!!!! //| [Low4/64]BRank(18):24K(1) R=+129402 p~= 0 FAIL !!!!!!!! //| [Low4/64]BRank(18):32K(2) R=+247300 p~= 0 FAIL !!!!!!!! //| [Low4/64]BRank(18):48K(1) R=+351219 p~= 0 FAIL !!!!!!!! //| [Low4/64]BRank(18):64K(1) R=+527569 p~= 0 FAIL !!!!!!!! //| [Low8/32]BRank(18):3K(8) R= +3598 p~= 2e-2310 FAIL !!!!!!!! //| [Low8/32]BRank(18):4K(32) R=+14990 p~= 0 FAIL !!!!!!!! //| [Low8/32]BRank(18):6K(8) R=+15289 p~= 4e-9814 FAIL !!!!!!!! //| [Low8/32]BRank(18):8K(16) R=+32644 p~= 0 FAIL !!!!!!!! //| [Low8/32]BRank(18):12K(4) R=+27344 p~= 0 FAIL !!!!!!!! //| [Low8/32]BRank(18):16K(16) R=+76731 p~= 0 FAIL !!!!!!!! //| [Low8/32]BRank(18):24K(4) R=+60410 p~= 0 FAIL !!!!!!!! //| [Low8/32]BRank(18):32K(8) R=+116607 p~= 0 FAIL !!!!!!!! //| [Low8/32]BRank(18):48K(2) R=+89478 p~= 0 FAIL !!!!!!!! //| [Low8/32]BRank(18):64K(5) R=+190769 p~= 0 FAIL !!!!!!!! //| [Low8/64]BRank(18):1536(8) R= +3598 p~= 2e-2310 FAIL !!!!!!!! //| [Low8/64]BRank(18):2K(16) R=+10600 p~= 3e-7802 FAIL !!!!!!!! //| [Low8/64]BRank(18):3K(4) R=+10811 p~= 1e-5750 FAIL !!!!!!!! //| [Low8/64]BRank(18):4K(16) R=+32644 p~= 0 FAIL !!!!!!!! //| [Low8/64]BRank(18):6K(4) R=+27344 p~= 0 FAIL !!!!!!!! //| [Low8/64]BRank(18):8K(8) R=+54257 p~= 0 FAIL !!!!!!!! //| [Low8/64]BRank(18):12K(2) R=+42716 p~= 0 FAIL !!!!!!!! //| [Low8/64]BRank(18):16K(8) R=+116607 p~= 0 FAIL !!!!!!!! //| [Low8/64]BRank(18):24K(2) R=+89478 p~= 0 FAIL !!!!!!!! //| [Low8/64]BRank(18):32K(4) R=+170629 p~= 0 FAIL !!!!!!!! //| [Low8/64]BRank(18):48K(1) R=+129402 p~= 0 FAIL !!!!!!!! //| [Low8/64]BRank(18):64K(2) R=+247300 p~= 0 FAIL !!!!!!!! //| ...and 1738 test result(s) without anomalies // // (it is, perhaps, worth noting that XorShift* 64/32, a generator half the // size of Xoroshiro128+ does not suffer these kinds of failures) // - 128 state bits, uint64_t output, period 2^128 - 1 using xoroshiro128plus64v0_1 = xoroshiro_detail::xoroshiro_plus<uint64_t, uint64_t, 55, 14, 36>; using xoroshiro128plus64v1_0 = xoroshiro_detail::xoroshiro_plus<uint64_t, uint64_t, 24, 16, 37>; using xoroshiro128plus64 = xoroshiro128plus64v1_0; using xoroshiro128starstar64v1_0 = xoroshiro_detail::xoroshiro_starstar<uint64_t, uint64_t, 24, 16, 37, 5, 7, 9>; using xoroshiro128starstar64 = xoroshiro128starstar64v1_0; // This is a variation on the above generator which tries to avoid the // problems with weak low-order bits by discarding the low-order bits, // to return only the high 32 bits. // - 128 state bits, uint32_t output, period 2^128 - 1 using xoroshiro128plus32v0_1 = xoroshiro_detail::xoroshiro_plus<uint64_t, uint32_t, 55, 14, 36>; using xoroshiro128plus32v1_0 = xoroshiro_detail::xoroshiro_plus<uint64_t, uint32_t, 24, 16, 37>; using xoroshiro128plus32 = xoroshiro128plus32v1_0; //// Variations //// // These are variations on the above theme. The constants are // mathematically correct and are designed to have a similar size // relationships to the constants for Xoroshiro128+. Empirical // testing shows them to be acceptable, but it is possible that there // are even better constants. // These variations have similar properties to the ones above. The // first variant fails statistical tests due to weak low-order bits, // and the second probably passes stringent statistical tests. // 256 // #if __SIZEOF_INT128__ // - 256 state bits, __uint128_t output, period 2^256 - 1 using xoroshiro256plus128 = xoroshiro_detail::xoroshiro_plus<__uint128_t, __uint128_t, 105, 36, 70>; // - 256 state bits, uint64_t output, period 2^256 - 1 using xoroshiro256plus64 = xoroshiro_detail::xoroshiro_plus<__uint128_t, uint64_t, 105, 36, 70>; #endif // 64 // // - 64 state bits, uint32_t output, period 2^64 - 1 using xoroshiro64plus32vMEO1 = xoroshiro_detail::xoroshiro_plus<uint32_t, uint32_t, 27, 7, 20>; using xoroshiro64plus32v1_0 = xoroshiro_detail::xoroshiro_plus<uint32_t, uint32_t, 26, 9, 13>; using xoroshiro64plus32 = xoroshiro64plus32v1_0; using xoroshiro64star32v1_0 = xoroshiro_detail::xoroshiro_star<uint32_t, uint32_t, 26, 9, 13, 0x9E3779BB>; using xoroshiro64star32 = xoroshiro64star32v1_0; using xoroshiro64starstar32v1_0 = xoroshiro_detail::xoroshiro_starstar<uint32_t, uint32_t, 26, 9, 13, 0x9E3779BB, 5, 5>; using xoroshiro64starstar32 = xoroshiro64starstar32v1_0; // - 64 state bits, uint16_t output, period 2^64 - 1 using xoroshiro64plus16vMEO1 = xoroshiro_detail::xoroshiro_plus<uint32_t, uint16_t, 27, 7, 20>; using xoroshiro64plus16v1_0 = xoroshiro_detail::xoroshiro_plus<uint32_t, uint16_t, 26, 9, 13>; using xoroshiro64plus16 = xoroshiro64plus16v1_0; // 32 // // - 32 state bits, uint16_t output, period 2^32 - 1 using xoroshiro32plus16 = xoroshiro_detail::xoroshiro_plus<uint16_t, uint16_t, 13, 5, 10>; using xoroshiro32star16 = xoroshiro_detail::xoroshiro_star<uint16_t, uint16_t, 13, 5, 10, 0x79BB>; // - 32 state bits, uint8_t output, period 2^32 - 1 using xoroshiro32plus8 = xoroshiro_detail::xoroshiro_plus<uint16_t, uint8_t, 13, 5, 10>; // 16 // // - 16 state bits, uint8_t output, period 2^16 - 1 using xoroshiro16plus8 = xoroshiro_detail::xoroshiro_plus<uint8_t, uint8_t, 4, 7, 3>; using xoroshiro16star8 = xoroshiro_detail::xoroshiro_star<uint8_t, uint8_t, 4, 7, 3, 0xBB>; #endif // XOROSHIRO_HPP_INCLUDED
; A211540: Number of ordered triples (w,x,y) with all terms in {1..n} and 2w = 3x + 4y. ; 0,0,0,0,0,1,1,2,3,4,5,7,8,10,12,14,16,19,21,24,27,30,33,37,40,44,48,52,56,61,65,70,75,80,85,91,96,102,108,114,120,127,133,140,147,154,161,169,176,184,192,200,208,217,225,234,243,252,261,271,280,290,300,310,320,331,341,352,363,374,385,397,408,420,432,444,456,469,481,494,507,520,533,547,560,574,588,602,616,631,645,660,675,690,705,721,736,752,768,784 sub $0,2 pow $0,2 mov $1,3619864 add $1,$0 div $1,12 sub $1,301655 mov $0,$1
############################################################################### # Copyright 2019 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material ("Material") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # "License"), the following terms apply: # # 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. ############################################################################### .text .p2align 6, 0x90 .globl _k0_EncryptCBC_RIJ128_AES_NI _k0_EncryptCBC_RIJ128_AES_NI: movslq %r8d, %r8 movdqu (%r9), %xmm0 .p2align 6, 0x90 .Lblks_loopgas_1: movdqu (%rdi), %xmm1 movdqa (%rcx), %xmm4 mov %rcx, %r9 pxor %xmm1, %xmm0 pxor %xmm4, %xmm0 movdqa (16)(%r9), %xmm4 add $(16), %r9 mov %rdx, %r10 sub $(1), %r10 .p2align 6, 0x90 .Lcipher_loopgas_1: aesenc %xmm4, %xmm0 movdqa (16)(%r9), %xmm4 add $(16), %r9 dec %r10 jnz .Lcipher_loopgas_1 aesenclast %xmm4, %xmm0 movdqu %xmm0, (%rsi) add $(16), %rdi add $(16), %rsi sub $(16), %r8 jnz .Lblks_loopgas_1 pxor %xmm4, %xmm4 vzeroupper ret
; void tshr_cls(uchar ink) SECTION code_clib SECTION code_arch PUBLIC _tshr_cls_fastcall EXTERN asm_tshr_cls defc _tshr_cls_fastcall = asm_tshr_cls
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r8 push %rbx push %rcx push %rdi push %rsi lea addresses_normal_ht+0xac26, %r12 nop nop nop sub $55289, %r10 movb (%r12), %bl nop nop cmp $28779, %r8 lea addresses_WT_ht+0xe26, %rsi lea addresses_UC_ht+0xe0a6, %rdi nop nop nop cmp %r8, %r8 mov $9, %rcx rep movsq nop nop nop cmp $64419, %rbx lea addresses_D_ht+0x41ca, %r8 nop xor %rbx, %rbx mov (%r8), %edi nop nop nop nop mfence lea addresses_D_ht+0xbca6, %r10 nop inc %r8 movw $0x6162, (%r10) nop nop nop nop dec %r8 lea addresses_normal_ht+0x5326, %r8 nop nop nop nop nop inc %rsi mov (%r8), %ebx dec %rcx pop %rsi pop %rdi pop %rcx pop %rbx pop %r8 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r15 push %rax push %rcx push %rdi push %rsi // Load lea addresses_RW+0x18c26, %r10 nop nop nop nop dec %rcx mov (%r10), %rsi nop nop nop cmp %r10, %r10 // Store mov $0xa6, %rsi nop nop nop nop and $9593, %rax mov $0x5152535455565758, %r10 movq %r10, (%rsi) nop nop nop nop sub $46423, %rsi // Store lea addresses_WT+0x1e2d5, %rax nop nop cmp %r15, %r15 movl $0x51525354, (%rax) sub %rax, %rax // Store lea addresses_WC+0x1d546, %rcx nop nop nop nop nop inc %r12 mov $0x5152535455565758, %r15 movq %r15, %xmm1 vmovups %ymm1, (%rcx) nop nop nop nop nop cmp %rdi, %rdi // Load mov $0x626, %r10 nop nop nop sub $50943, %r12 mov (%r10), %ax nop sub %r10, %r10 // Store lea addresses_A+0x10c86, %rax and %r10, %r10 movl $0x51525354, (%rax) nop nop nop dec %rsi // Store lea addresses_D+0x103a6, %rax nop nop nop sub %rcx, %rcx movw $0x5152, (%rax) nop nop cmp $61277, %r12 // Faulty Load lea addresses_RW+0x18c26, %r15 nop nop nop cmp %rsi, %rsi mov (%r15), %edi lea oracles, %r15 and $0xff, %rdi shlq $12, %rdi mov (%r15,%rdi,1), %rdi pop %rsi pop %rdi pop %rcx pop %rax pop %r15 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_P', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_P', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'32': 2} 32 32 */
; A035214: 2 followed by a run of n 1's. ; 2,2,1,2,1,1,2,1,1,1,2,1,1,1,1,2,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 lpb $0 add $2,1 sub $0,$2 lpe mov $1,$0 cmp $1,0 add $1,1
addiu $0,$3,-32026 srl $4,$3,19 addiu $4,$3,14042 sra $5,$3,1 addu $1,$1,$3 subu $1,$5,$3 srav $0,$0,$3 slt $6,$0,$3 sllv $6,$3,$3 addiu $0,$0,26983 sll $1,$5,5 andi $3,$3,36232 ori $1,$1,25178 lh $1,2($0) sb $3,15($0) lb $1,1($0) srav $4,$2,$3 sb $5,13($0) addiu $4,$5,-23423 addiu $3,$1,29948 lb $0,2($0) ori $3,$3,27987 sltu $4,$4,$3 slti $3,$3,11297 addu $5,$1,$3 sra $1,$0,15 lw $5,0($0) addiu $3,$3,2303 ori $5,$5,17306 subu $3,$3,$3 sltu $4,$4,$3 sltiu $3,$3,2531 sw $3,8($0) addu $4,$4,$3 sra $3,$3,27 addu $6,$5,$3 nor $3,$1,$3 xor $4,$5,$3 sb $6,12($0) xor $3,$4,$3 xor $4,$4,$3 sltu $3,$5,$3 sllv $5,$1,$3 lhu $5,14($0) slt $1,$4,$3 and $0,$4,$3 srl $1,$1,25 addu $0,$0,$3 sh $4,14($0) sra $3,$3,8 sltu $5,$4,$3 srlv $3,$4,$3 sb $3,7($0) and $4,$4,$3 sb $0,1($0) lb $5,5($0) srav $5,$1,$3 sllv $6,$3,$3 subu $1,$3,$3 xor $6,$3,$3 slti $1,$1,-17248 lbu $3,2($0) sltiu $3,$3,-28144 lh $4,12($0) sw $4,8($0) addiu $5,$4,-15064 addiu $3,$4,-10405 subu $3,$6,$3 nor $3,$4,$3 sw $5,0($0) lw $1,16($0) addu $6,$6,$3 ori $3,$1,32830 addu $0,$6,$3 lhu $3,0($0) sllv $3,$5,$3 sb $6,10($0) lh $5,16($0) or $6,$6,$3 slt $0,$5,$3 sltiu $5,$3,11751 sltu $5,$0,$3 addiu $0,$4,-12415 xori $3,$4,60460 lb $3,8($0) sw $4,0($0) lhu $6,8($0) slti $3,$3,-31249 sltiu $3,$6,15788 sllv $1,$5,$3 srav $6,$3,$3 subu $3,$3,$3 lh $1,0($0) subu $3,$3,$3 srav $4,$1,$3 lh $3,6($0) ori $4,$5,59224 lw $4,8($0) lh $4,12($0) sltu $6,$6,$3 ori $0,$3,58006 nor $0,$1,$3 addu $5,$4,$3 nor $0,$0,$3 sw $1,12($0) sw $3,0($0) addu $3,$1,$3 lhu $6,2($0) sllv $0,$5,$3 sra $5,$3,30 slt $3,$4,$3 sllv $4,$6,$3 sllv $5,$3,$3 addu $3,$3,$3 or $4,$3,$3 addu $1,$1,$3 xori $4,$3,61776 xori $3,$4,47463 or $4,$3,$3 and $3,$2,$3 ori $3,$5,8108 sb $3,12($0) nor $4,$6,$3 and $2,$2,$3 lb $1,3($0) slt $3,$4,$3 sltu $4,$3,$3 subu $6,$5,$3 addiu $1,$1,-11489 nor $4,$4,$3 addiu $4,$3,29564 nor $3,$1,$3 slti $5,$6,26541 xori $4,$0,12665 sb $1,14($0) lbu $4,4($0) sltu $3,$3,$3 nor $1,$0,$3 xor $5,$1,$3 sllv $1,$1,$3 sllv $5,$5,$3 nor $3,$4,$3 ori $5,$5,26209 sw $1,16($0) addu $3,$3,$3 slt $3,$6,$3 slt $3,$2,$3 lbu $5,3($0) sll $3,$3,29 addu $0,$3,$3 nor $3,$5,$3 subu $3,$0,$3 nor $4,$3,$3 slt $4,$3,$3 sltiu $3,$3,24832 srl $5,$6,19 sltu $1,$1,$3 slt $3,$4,$3 xor $3,$4,$3 lhu $4,14($0) subu $1,$4,$3 srav $4,$3,$3 srav $0,$0,$3 addu $3,$5,$3 ori $3,$4,49362 addu $3,$3,$3 subu $3,$3,$3 andi $3,$5,3247 subu $3,$3,$3 srl $5,$5,1 lbu $0,9($0) sh $4,8($0) lbu $4,3($0) sllv $1,$6,$3 sltu $6,$4,$3 subu $3,$3,$3 sll $3,$3,7 addiu $3,$3,16689 addu $3,$3,$3 sh $3,10($0) lw $3,8($0) nor $3,$3,$3 xori $4,$0,18039 lw $3,4($0) subu $0,$3,$3 lh $1,10($0) lb $4,14($0) srl $5,$4,31 lhu $3,12($0) sra $1,$4,26 lh $6,12($0) sra $1,$3,11 andi $5,$2,30661 subu $1,$3,$3 nor $3,$4,$3 sb $6,6($0) subu $5,$6,$3 srl $1,$3,21 srl $4,$4,5 addiu $4,$4,15953 sra $3,$4,21 lhu $6,14($0) subu $5,$1,$3 addu $4,$4,$3 addu $3,$3,$3 srav $6,$3,$3 addu $0,$0,$3 lh $1,2($0) sb $6,10($0) lw $4,8($0) srav $1,$1,$3 sltu $5,$0,$3 sra $5,$1,3 sltu $3,$3,$3 or $4,$4,$3 sw $6,4($0) sltiu $0,$3,9674 sllv $3,$0,$3 lb $3,16($0) subu $3,$6,$3 xor $3,$5,$3 sllv $1,$0,$3 subu $3,$5,$3 subu $3,$5,$3 lb $5,9($0) nor $4,$3,$3 sb $0,14($0) lb $1,3($0) ori $6,$1,10945 xori $3,$3,38690 xori $0,$4,33577 and $4,$4,$3 srav $6,$5,$3 addu $0,$3,$3 srav $4,$4,$3 addu $3,$3,$3 sll $4,$4,23 andi $1,$3,54312 slti $4,$3,-526 andi $4,$6,1520 sh $4,10($0) addu $1,$2,$3 sltu $3,$3,$3 lh $3,0($0) lb $4,15($0) lw $4,16($0) or $4,$3,$3 xori $5,$5,21982 xor $6,$6,$3 lh $4,14($0) sltu $4,$6,$3 andi $5,$5,4138 lw $4,0($0) lh $3,0($0) addiu $4,$1,-10508 addu $5,$4,$3 and $5,$5,$3 addiu $1,$1,3519 sllv $1,$1,$3 sh $3,6($0) sw $3,4($0) lbu $3,15($0) addiu $1,$1,-762 srlv $4,$4,$3 andi $3,$3,19109 ori $1,$3,36189 addiu $4,$3,16952 lw $0,0($0) andi $0,$5,59167 ori $4,$4,64023 sh $3,2($0) lh $3,16($0) sll $6,$3,30 srlv $4,$3,$3 sra $6,$1,4 subu $3,$4,$3 sllv $4,$6,$3 addiu $4,$1,28936 sw $3,4($0) subu $5,$4,$3 sra $3,$3,11 or $3,$2,$3 addiu $1,$5,-11582 ori $3,$3,55844 srl $3,$3,20 srlv $4,$0,$3 lw $6,12($0) and $6,$6,$3 sh $4,8($0) sra $3,$5,26 addu $3,$5,$3 srl $3,$0,16 lhu $6,12($0) addu $3,$1,$3 and $3,$4,$3 sw $0,0($0) or $1,$1,$3 xor $5,$3,$3 addiu $4,$3,19724 lh $3,14($0) srav $1,$5,$3 sltiu $4,$4,-10917 sll $5,$5,16 lb $6,3($0) sh $0,14($0) slt $6,$6,$3 lhu $3,2($0) slti $3,$3,28574 sltiu $3,$3,-3413 slt $4,$6,$3 addiu $3,$1,-2803 addu $3,$5,$3 ori $3,$3,4794 xor $1,$3,$3 sb $5,3($0) lh $3,4($0) nor $5,$3,$3 addiu $1,$3,-18073 subu $4,$6,$3 lhu $0,0($0) sra $0,$4,27 lhu $3,0($0) addu $4,$0,$3 sltu $3,$1,$3 srlv $3,$5,$3 nor $1,$3,$3 srl $5,$0,19 sltiu $3,$3,17136 sllv $3,$3,$3 srl $4,$3,0 addiu $1,$0,-7534 lbu $5,0($0) sw $6,4($0) srav $1,$1,$3 lb $4,10($0) or $0,$4,$3 or $3,$4,$3 sllv $5,$1,$3 sll $4,$5,31 subu $3,$4,$3 sb $4,5($0) slt $6,$5,$3 slti $5,$4,28283 slt $0,$0,$3 slti $3,$0,-22877 subu $0,$6,$3 srlv $4,$5,$3 sltiu $5,$3,-27897 and $1,$3,$3 andi $3,$3,8104 lh $4,16($0) lbu $5,7($0) slti $1,$0,-24313 lhu $1,4($0) lb $0,12($0) sll $1,$1,26 lhu $4,0($0) lbu $6,9($0) xor $4,$0,$3 lhu $3,10($0) sh $1,2($0) addu $4,$1,$3 sltu $1,$3,$3 ori $6,$3,6867 sra $3,$3,24 sll $3,$0,27 ori $0,$0,42690 ori $3,$5,52973 nor $4,$5,$3 lbu $3,14($0) sltiu $4,$4,-11862 lhu $4,2($0) srl $0,$6,26 sb $3,10($0) addu $3,$4,$3 srlv $3,$1,$3 addu $1,$4,$3 sllv $1,$1,$3 srl $5,$4,16 andi $3,$6,12184 sra $5,$4,14 ori $4,$4,55743 addiu $1,$4,16915 lh $4,2($0) addiu $4,$3,-2511 subu $1,$1,$3 or $1,$3,$3 srl $0,$3,0 sh $3,2($0) srav $1,$3,$3 subu $0,$4,$3 lw $3,16($0) slti $4,$4,-6331 addu $4,$5,$3 addu $3,$4,$3 lb $1,8($0) xor $3,$3,$3 xori $1,$4,51400 lbu $3,2($0) sh $3,14($0) lb $1,16($0) sllv $4,$3,$3 addiu $3,$3,1770 lb $4,8($0) sw $3,4($0) addiu $3,$4,-25227 or $4,$0,$3 and $3,$3,$3 or $1,$5,$3 addiu $3,$3,-7299 subu $4,$1,$3 xori $1,$1,42756 ori $5,$0,35147 sllv $6,$4,$3 lh $6,4($0) srl $1,$4,3 subu $6,$6,$3 addiu $3,$2,-17948 or $4,$1,$3 addu $0,$0,$3 slt $0,$1,$3 addu $1,$3,$3 lw $4,4($0) srav $1,$1,$3 lh $2,8($0) slt $3,$3,$3 lw $5,8($0) lb $1,2($0) srlv $1,$3,$3 subu $4,$5,$3 addiu $4,$3,20978 lh $3,0($0) nor $3,$6,$3 nor $6,$0,$3 lhu $4,0($0) sll $0,$0,4 srlv $4,$4,$3 nor $3,$3,$3 nor $4,$3,$3 and $0,$3,$3 lw $4,0($0) addu $6,$1,$3 addu $1,$5,$3 subu $0,$0,$3 addu $3,$5,$3 and $3,$6,$3 ori $5,$3,44752 nor $4,$3,$3 sltiu $1,$4,2608 addu $1,$6,$3 sb $5,15($0) sll $3,$0,28 sltiu $4,$3,-17585 sltiu $1,$1,28716 sltu $5,$0,$3 sb $1,8($0) addu $6,$6,$3 lw $5,4($0) sltu $5,$3,$3 andi $1,$1,51471 ori $1,$4,23249 and $3,$3,$3 and $1,$1,$3 or $5,$5,$3 addiu $0,$0,-8802 addiu $4,$3,19915 sb $4,10($0) addu $3,$4,$3 slt $1,$4,$3 sh $4,2($0) lb $1,10($0) lhu $5,12($0) lh $3,10($0) srlv $6,$2,$3 lw $5,16($0) sw $3,8($0) srl $1,$5,7 subu $5,$3,$3 lw $4,4($0) lhu $4,12($0) addiu $1,$4,-17151 addiu $1,$0,31787 andi $0,$1,11693 sw $5,0($0) lw $4,16($0) subu $3,$3,$3 xori $6,$1,54871 sll $1,$1,15 addu $3,$3,$3 addu $5,$3,$3 subu $2,$2,$3 sh $0,10($0) subu $3,$4,$3 srl $6,$1,5 xor $6,$6,$3 slt $5,$5,$3 addiu $1,$1,18692 srav $4,$5,$3 srl $4,$6,6 sra $5,$1,20 addiu $3,$6,-1266 ori $3,$5,20903 srl $3,$4,24 lbu $1,13($0) slt $3,$5,$3 sltu $5,$0,$3 andi $1,$1,45441 subu $4,$5,$3 or $1,$4,$3 addiu $0,$5,-32705 srlv $0,$0,$3 addu $5,$1,$3 lh $0,0($0) addu $3,$5,$3 ori $1,$1,947 subu $0,$4,$3 or $4,$0,$3 addiu $3,$1,-7629 or $4,$4,$3 sw $3,4($0) lhu $4,16($0) srlv $6,$1,$3 sltiu $3,$6,-26628 sltiu $3,$3,31849 sra $4,$4,0 addu $1,$1,$3 subu $3,$0,$3 srlv $3,$6,$3 sllv $0,$6,$3 lhu $3,12($0) srav $3,$3,$3 addiu $4,$4,-24160 sltiu $3,$1,-7943 sra $3,$4,11 or $3,$4,$3 subu $4,$4,$3 addiu $4,$5,-6418 subu $3,$3,$3 sra $1,$5,24 xori $4,$5,13167 xor $4,$4,$3 lh $5,4($0) xor $4,$4,$3 andi $1,$3,54714 or $1,$1,$3 sllv $5,$5,$3 srav $3,$3,$3 sb $1,14($0) slti $3,$3,17059 lbu $3,8($0) sltu $1,$3,$3 lb $3,5($0) sra $5,$3,9 xori $5,$3,18731 addu $3,$3,$3 lbu $3,12($0) sltu $3,$3,$3 sh $4,10($0) srav $3,$4,$3 lh $1,16($0) sltu $3,$3,$3 or $4,$3,$3 sltiu $6,$6,25896 xor $5,$5,$3 lh $5,14($0) addu $0,$6,$3 xor $3,$4,$3 subu $0,$4,$3 sh $1,14($0) lhu $3,8($0) or $3,$3,$3 xor $5,$3,$3 nor $3,$4,$3 xor $4,$3,$3 addiu $6,$6,-25794 sb $4,7($0) addiu $3,$3,10574 sltu $0,$1,$3 lb $6,4($0) addu $6,$0,$3 srl $3,$3,8 srav $4,$1,$3 sra $4,$4,24 srl $4,$6,25 xori $3,$1,7712 lb $5,1($0) lw $4,4($0) sw $4,0($0) slti $3,$4,21460 ori $0,$3,56516 srav $4,$1,$3 lw $5,8($0) sltiu $0,$1,-29428 or $1,$1,$3 nor $3,$3,$3 ori $5,$4,5988 sw $4,16($0) andi $3,$0,18692 andi $4,$3,34118 lbu $5,16($0) and $5,$1,$3 lw $0,8($0) addiu $6,$4,6848 addu $1,$6,$3 slt $0,$0,$3 lbu $6,16($0) srlv $5,$6,$3 addiu $5,$1,-18327 slt $4,$2,$3 subu $1,$4,$3 srav $4,$4,$3 sra $4,$3,12 sb $1,14($0) sltu $6,$2,$3 sll $1,$0,22 addiu $3,$1,11192 lb $4,6($0) srlv $4,$4,$3 or $5,$5,$3 srlv $0,$1,$3 andi $1,$3,9547 or $6,$1,$3 lh $4,16($0) sltiu $3,$0,11462 sltu $3,$1,$3 sll $5,$3,14 addiu $6,$3,26424 srlv $3,$3,$3 slti $3,$3,30524 srl $6,$5,21 slt $3,$3,$3 ori $4,$1,6966 lhu $4,0($0) sltu $3,$1,$3 ori $4,$4,2030 srlv $3,$3,$3 addiu $6,$1,11762 or $3,$4,$3 ori $1,$0,1470 lh $1,4($0) ori $1,$5,19525 srav $6,$4,$3 lh $4,12($0) sltiu $4,$3,-31622 sllv $3,$0,$3 lw $3,4($0) addu $5,$3,$3 lhu $3,16($0) sllv $5,$5,$3 and $6,$6,$3 sb $3,10($0) lh $4,10($0) subu $5,$1,$3 sll $1,$3,28 slti $1,$4,8707 srl $4,$2,18 addiu $3,$3,-32171 addu $3,$6,$3 sb $5,9($0) slt $3,$6,$3 srl $4,$3,24 lh $4,14($0) sra $0,$0,10 nor $4,$1,$3 srlv $3,$3,$3 sb $3,0($0) lbu $0,6($0) subu $1,$0,$3 sh $5,8($0) or $0,$4,$3 sb $1,15($0) addu $3,$3,$3 addu $3,$1,$3 subu $3,$3,$3 xor $1,$3,$3 slt $3,$3,$3 lh $1,2($0) sb $0,8($0) sw $5,12($0) xori $1,$3,9881 ori $1,$3,37268 sh $3,6($0) srav $5,$1,$3 ori $5,$0,5233 nor $1,$5,$3 and $1,$3,$3 sltiu $0,$1,-11564 srlv $3,$6,$3 lhu $0,10($0) slt $5,$4,$3 addiu $3,$3,-18737 sw $4,4($0) andi $5,$1,4467 sllv $1,$1,$3 xor $0,$3,$3 or $3,$0,$3 lb $0,15($0) sll $4,$4,29 sltiu $5,$1,24241 srlv $3,$4,$3 lbu $4,11($0) or $1,$5,$3 sltiu $1,$1,-3716 addiu $1,$3,-17386 sll $3,$3,6 lw $6,16($0) or $0,$2,$3 xor $6,$1,$3 subu $5,$3,$3 lh $3,16($0) sra $0,$0,12 xori $0,$3,43924 lb $3,0($0) or $4,$3,$3 nor $1,$1,$3 nor $4,$3,$3 addu $3,$1,$3 xor $3,$4,$3 or $6,$5,$3 and $3,$3,$3 ori $1,$1,11710 sra $3,$6,0 slti $4,$5,27263 and $1,$5,$3 xori $3,$0,5581 sllv $5,$3,$3 ori $4,$2,9864 lw $5,8($0) addu $1,$1,$3 addu $0,$0,$3 sra $4,$4,1 slti $5,$5,-14604 slti $4,$4,-22030 lbu $1,7($0) lhu $6,2($0) lh $1,10($0) srlv $0,$5,$3 slt $6,$2,$3 sw $4,16($0) sllv $6,$4,$3 lbu $5,4($0) sh $5,4($0) sb $6,12($0) or $3,$3,$3 srlv $6,$5,$3 lbu $4,11($0) and $3,$6,$3 srav $3,$3,$3 lw $5,8($0) srav $3,$3,$3 addiu $1,$5,29482 sh $4,12($0) lbu $3,5($0) ori $1,$1,46494 addiu $1,$5,21136 addiu $3,$5,-28382 addu $5,$3,$3 xor $1,$1,$3 addiu $0,$0,-18451 sh $5,4($0) lbu $3,10($0) sllv $4,$6,$3 addu $1,$6,$3 ori $4,$6,33555 subu $3,$4,$3 sll $4,$1,5 srav $5,$0,$3 lb $1,1($0) lh $1,4($0) sw $4,8($0) lbu $3,15($0) lb $3,13($0) sllv $3,$2,$3 sw $1,16($0) srl $4,$4,20 addu $0,$0,$3 addiu $6,$6,29083 lbu $5,4($0) lw $5,4($0) sw $4,16($0) srav $3,$4,$3 lh $4,16($0) addu $3,$3,$3 lbu $4,14($0) or $6,$6,$3 ori $4,$4,61452 addiu $0,$0,-26670 slti $5,$5,-24702 nor $0,$4,$3 slt $6,$3,$3 or $0,$0,$3 nor $4,$4,$3 srl $4,$1,27 ori $4,$4,59172 srav $3,$1,$3 sra $3,$0,28 addu $3,$0,$3 lw $4,0($0) srav $5,$6,$3 lbu $5,0($0) lbu $3,5($0) xori $4,$1,10079 and $4,$3,$3 sll $4,$5,29 sb $3,12($0) subu $4,$3,$3 srav $1,$2,$3 and $4,$2,$3 or $0,$4,$3 andi $1,$3,60649 lb $3,15($0) sra $4,$4,4 srl $5,$0,27 lhu $5,2($0) srlv $3,$4,$3 sw $3,12($0) lb $0,14($0) sltiu $5,$3,-6488 sw $3,16($0) sb $6,5($0) slt $0,$6,$3 lb $1,5($0) sra $1,$3,11 andi $3,$0,1878 addiu $0,$4,1548 xor $3,$6,$3 addiu $4,$3,-30624 nor $0,$3,$3 sllv $6,$3,$3 sh $1,12($0) lh $5,16($0) sb $5,8($0) subu $4,$5,$3 sll $0,$3,16 sltu $1,$3,$3 subu $3,$4,$3 lhu $1,8($0) srl $1,$4,8 lbu $4,5($0) subu $5,$5,$3 and $6,$6,$3 slt $6,$1,$3 or $5,$4,$3 subu $0,$2,$3 sllv $5,$3,$3 sh $1,6($0) srlv $3,$0,$3 srl $0,$0,15 lb $3,8($0) xor $5,$5,$3 srl $3,$4,31 slti $3,$3,-9290 lbu $1,5($0) ori $3,$3,50660 addu $6,$4,$3 or $5,$5,$3 sll $4,$4,15 subu $3,$3,$3 sra $6,$0,0 sw $4,16($0) srlv $3,$3,$3 nor $4,$3,$3 lb $3,1($0) lh $3,8($0) andi $3,$3,26308 sllv $5,$5,$3 sw $3,12($0) sh $5,8($0) sh $4,14($0) srlv $5,$3,$3 subu $6,$3,$3 sra $0,$0,24 xor $5,$3,$3 lbu $3,14($0) addu $4,$1,$3 sh $0,14($0) sw $4,12($0) srl $1,$6,19 addiu $4,$5,-29392 slt $4,$4,$3 and $3,$1,$3 sll $3,$1,30 or $3,$3,$3 nor $3,$1,$3 sllv $1,$3,$3 or $6,$3,$3 slt $6,$6,$3 nor $4,$2,$3
// // Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // #include "Preprocessor.h" #include <cassert> #include <sstream> #include "Diagnostics.h" #include "DirectiveParser.h" #include "Macro.h" #include "MacroExpander.h" #include "Token.h" #include "Tokenizer.h" namespace pp { struct PreprocessorImpl { Diagnostics* diagnostics; MacroSet macroSet; Tokenizer tokenizer; DirectiveParser directiveParser; MacroExpander macroExpander; PreprocessorImpl(Diagnostics* diag, DirectiveHandler* directiveHandler) : diagnostics(diag), tokenizer(diag), directiveParser(&tokenizer, &macroSet, diag, directiveHandler), macroExpander(&directiveParser, &macroSet, diag) { } }; Preprocessor::Preprocessor(Diagnostics* diagnostics, DirectiveHandler* directiveHandler) { mImpl = new PreprocessorImpl(diagnostics, directiveHandler); } Preprocessor::~Preprocessor() { delete mImpl; } bool Preprocessor::init(int count, const char* const string[], const int length[]) { static const int kGLSLVersion = 100; // Add standard pre-defined macros. predefineMacro("__LINE__", 0); predefineMacro("__FILE__", 0); predefineMacro("__VERSION__", kGLSLVersion); predefineMacro("GL_ES", 1); return mImpl->tokenizer.init(count, string, length); } void Preprocessor::predefineMacro(const char* name, int value) { std::ostringstream stream; stream << value; Token token; token.type = Token::CONST_INT; token.text = stream.str(); Macro macro; macro.predefined = true; macro.type = Macro::kTypeObj; macro.name = name; macro.replacements.push_back(token); mImpl->macroSet[name] = macro; } void Preprocessor::lex(Token* token) { bool validToken = false; while (!validToken) { mImpl->macroExpander.lex(token); switch (token->type) { // We should not be returning internal preprocessing tokens. // Convert preprocessing tokens to compiler tokens or report // diagnostics. case Token::PP_HASH: assert(false); break; case Token::CONST_INT: { int val = 0; if (!token->iValue(&val)) { // Do not mark the token as invalid. // Just emit the diagnostic and reset value to 0. mImpl->diagnostics->report(Diagnostics::INTEGER_OVERFLOW, token->location, token->text); token->text.assign("0"); } validToken = true; break; } case Token::CONST_FLOAT: { float val = 0; if (!token->fValue(&val)) { // Do not mark the token as invalid. // Just emit the diagnostic and reset value to 0.0. mImpl->diagnostics->report(Diagnostics::FLOAT_OVERFLOW, token->location, token->text); token->text.assign("0.0"); } validToken = true; break; } case Token::PP_NUMBER: mImpl->diagnostics->report(Diagnostics::INVALID_NUMBER, token->location, token->text); break; case Token::PP_OTHER: mImpl->diagnostics->report(Diagnostics::INVALID_CHARACTER, token->location, token->text); break; default: validToken = true; break; } } } } // namespace pp
; A130453: A097806 * A059268. ; 1,2,2,2,4,4,2,4,8,8,2,4,8,16,16,2,4,8,16,32,32,2,4,8,16,32,64,64,2,4,8,16,32,64,128,128 seq $0,128219 ; A000012 * A127701. a(1) = 1, a(2) = 2, a(3) = 2; by rows, n-1 terms of 2, 3, 4...followed by "n". seq $0,304517 ; a(n) = 16*2^n - 11 (n>=1). div $0,64 add $0,1
; A007283: a(n) = 3*2^n. ; 3,6,12,24,48,96,192,384,768,1536,3072,6144,12288,24576,49152,98304,196608,393216,786432,1572864,3145728,6291456,12582912,25165824,50331648,100663296,201326592,402653184,805306368,1610612736,3221225472,6442450944,12884901888,25769803776,51539607552,103079215104,206158430208,412316860416,824633720832,1649267441664,3298534883328,6597069766656,13194139533312,26388279066624,52776558133248,105553116266496,211106232532992,422212465065984,844424930131968,1688849860263936,3377699720527872 mov $1,2 pow $1,$0 mul $1,3 mov $0,$1
.globl Tela59 Tela59: addi $10, $0, 0xcff8cf sw $10, 268500992($0) addi $10, $0, 0x00d800 sw $10, 268500996($0) addi $10, $0, 0x00d800 sw $10, 268501000($0) addi $10, $0, 0x00d800 sw $10, 268501004($0) addi $10, $0, 0x00d800 sw $10, 268501008($0) addi $10, $0, 0x00d800 sw $10, 268501012($0) addi $10, $0, 0x00d800 sw $10, 268501016($0) addi $10, $0, 0x00d800 sw $10, 268501020($0) addi $10, $0, 0x00d800 sw $10, 268501024($0) addi $10, $0, 0x00d800 sw $10, 268501028($0) addi $10, $0, 0x00d800 sw $10, 268501032($0) addi $10, $0, 0x00d800 sw $10, 268501036($0) addi $10, $0, 0x00d800 sw $10, 268501040($0) addi $10, $0, 0x00d800 sw $10, 268501044($0) addi $10, $0, 0x00d800 sw $10, 268501048($0) addi $10, $0, 0x00d800 sw $10, 268501052($0) addi $10, $0, 0x00d800 sw $10, 268501056($0) addi $10, $0, 0x00d800 sw $10, 268501060($0) addi $10, $0, 0x00d800 sw $10, 268501064($0) addi $10, $0, 0x00d800 sw $10, 268501068($0) addi $10, $0, 0x00d800 sw $10, 268501072($0) addi $10, $0, 0x00d800 sw $10, 268501076($0) addi $10, $0, 0x00d800 sw $10, 268501080($0) addi $10, $0, 0x00d800 sw $10, 268501084($0) addi $10, $0, 0x00d800 sw $10, 268501088($0) addi $10, $0, 0x00d800 sw $10, 268501092($0) addi $10, $0, 0x00d800 sw $10, 268501096($0) addi $10, $0, 0x00d800 sw $10, 268501100($0) addi $10, $0, 0x00d800 sw $10, 268501104($0) addi $10, $0, 0x00d800 sw $10, 268501108($0) addi $10, $0, 0x00d800 sw $10, 268501112($0) addi $10, $0, 0x00d800 sw $10, 268501116($0) addi $10, $0, 0x00d800 sw $10, 268501120($0) addi $10, $0, 0x00d800 sw $10, 268501124($0) addi $10, $0, 0x00d800 sw $10, 268501128($0) addi $10, $0, 0x00d800 sw $10, 268501132($0) addi $10, $0, 0x00d800 sw $10, 268501136($0) addi $10, $0, 0x00d800 sw $10, 268501140($0) addi $10, $0, 0x00d800 sw $10, 268501144($0) addi $10, $0, 0x00d800 sw $10, 268501148($0) addi $10, $0, 0x00d800 sw $10, 268501152($0) addi $10, $0, 0x00d800 sw $10, 268501156($0) addi $10, $0, 0x00d800 sw $10, 268501160($0) addi $10, $0, 0x00d800 sw $10, 268501164($0) addi $10, $0, 0x00d800 sw $10, 268501168($0) addi $10, $0, 0x00d800 sw $10, 268501172($0) addi $10, $0, 0x00d800 sw $10, 268501176($0) addi $10, $0, 0x00d800 sw $10, 268501180($0) addi $10, $0, 0x00d800 sw $10, 268501184($0) addi $10, $0, 0x00d800 sw $10, 268501188($0) addi $10, $0, 0x00d800 sw $10, 268501192($0) addi $10, $0, 0x00d800 sw $10, 268501196($0) addi $10, $0, 0x00d800 sw $10, 268501200($0) addi $10, $0, 0x00d800 sw $10, 268501204($0) addi $10, $0, 0x00d800 sw $10, 268501208($0) addi $10, $0, 0x00d800 sw $10, 268501212($0) addi $10, $0, 0x00d800 sw $10, 268501216($0) addi $10, $0, 0x00d800 sw $10, 268501220($0) addi $10, $0, 0x00d800 sw $10, 268501224($0) addi $10, $0, 0x00d800 sw $10, 268501228($0) addi $10, $0, 0x00d800 sw $10, 268501232($0) addi $10, $0, 0x00d800 sw $10, 268501236($0) addi $10, $0, 0x00d800 sw $10, 268501240($0) addi $10, $0, 0x00d800 sw $10, 268501244($0) addi $10, $0, 0x00d800 sw $10, 268501248($0) addi $10, $0, 0xffffff sw $10, 268501252($0) addi $10, $0, 0xffffff sw $10, 268501256($0) addi $10, $0, 0xffffff sw $10, 268501260($0) addi $10, $0, 0xffffff sw $10, 268501264($0) addi $10, $0, 0xffffff sw $10, 268501268($0) addi $10, $0, 0xffffff sw $10, 268501272($0) addi $10, $0, 0xffffff sw $10, 268501276($0) addi $10, $0, 0xffffff sw $10, 268501280($0) addi $10, $0, 0xffffff sw $10, 268501284($0) addi $10, $0, 0xffffff sw $10, 268501288($0) addi $10, $0, 0xffffff sw $10, 268501292($0) addi $10, $0, 0xffffff sw $10, 268501296($0) addi $10, $0, 0xffffff sw $10, 268501300($0) addi $10, $0, 0xffffff sw $10, 268501304($0) addi $10, $0, 0xffffff sw $10, 268501308($0) addi $10, $0, 0xffffff sw $10, 268501312($0) addi $10, $0, 0xffffff sw $10, 268501316($0) addi $10, $0, 0xffffff sw $10, 268501320($0) addi $10, $0, 0xffffff sw $10, 268501324($0) addi $10, $0, 0xffffff sw $10, 268501328($0) addi $10, $0, 0xffffff sw $10, 268501332($0) addi $10, $0, 0xffffff sw $10, 268501336($0) addi $10, $0, 0xffffff sw $10, 268501340($0) addi $10, $0, 0xffffff sw $10, 268501344($0) addi $10, $0, 0xffffff sw $10, 268501348($0) addi $10, $0, 0xffffff sw $10, 268501352($0) addi $10, $0, 0xffffff sw $10, 268501356($0) addi $10, $0, 0xffffff sw $10, 268501360($0) addi $10, $0, 0xffffff sw $10, 268501364($0) addi $10, $0, 0xffffff sw $10, 268501368($0) addi $10, $0, 0xffffff sw $10, 268501372($0) addi $10, $0, 0xffffff sw $10, 268501376($0) addi $10, $0, 0xffffff sw $10, 268501380($0) addi $10, $0, 0xffffff sw $10, 268501384($0) addi $10, $0, 0xffffff sw $10, 268501388($0) addi $10, $0, 0xffffff sw $10, 268501392($0) addi $10, $0, 0xffffff sw $10, 268501396($0) addi $10, $0, 0xffffff sw $10, 268501400($0) addi $10, $0, 0xffffff sw $10, 268501404($0) addi $10, $0, 0xffffff sw $10, 268501408($0) addi $10, $0, 0xffffff sw $10, 268501412($0) addi $10, $0, 0xffffff sw $10, 268501416($0) addi $10, $0, 0xffffff sw $10, 268501420($0) addi $10, $0, 0xffffff sw $10, 268501424($0) addi $10, $0, 0xffffff sw $10, 268501428($0) addi $10, $0, 0xffffff sw $10, 268501432($0) addi $10, $0, 0xffffff sw $10, 268501436($0) addi $10, $0, 0xffffff sw $10, 268501440($0) addi $10, $0, 0xffffff sw $10, 268501444($0) addi $10, $0, 0xffffff sw $10, 268501448($0) addi $10, $0, 0xffffff sw $10, 268501452($0) addi $10, $0, 0xffffff sw $10, 268501456($0) addi $10, $0, 0xffffff sw $10, 268501460($0) addi $10, $0, 0xffffff sw $10, 268501464($0) addi $10, $0, 0xffffff sw $10, 268501468($0) addi $10, $0, 0xffffff sw $10, 268501472($0) addi $10, $0, 0xffffff sw $10, 268501476($0) addi $10, $0, 0xffffff sw $10, 268501480($0) addi $10, $0, 0xffffff sw $10, 268501484($0) addi $10, $0, 0xffffff sw $10, 268501488($0) addi $10, $0, 0xffffff sw $10, 268501492($0) addi $10, $0, 0xffffff sw $10, 268501496($0) addi $10, $0, 0x00d800 sw $10, 268501500($0) addi $10, $0, 0x00d800 sw $10, 268501504($0) addi $10, $0, 0xffffff sw $10, 268501508($0) addi $10, $0, 0xfefefe sw $10, 268501512($0) addi $10, $0, 0xfdfdfd sw $10, 268501516($0) addi $10, $0, 0xfcfcfc sw $10, 268501520($0) addi $10, $0, 0xfcfcfc sw $10, 268501524($0) addi $10, $0, 0xfcfcfc sw $10, 268501528($0) addi $10, $0, 0xfcfcfc sw $10, 268501532($0) addi $10, $0, 0xfcfcfc sw $10, 268501536($0) addi $10, $0, 0xfcfcfc sw $10, 268501540($0) addi $10, $0, 0xfcfcfc sw $10, 268501544($0) addi $10, $0, 0xfcfcfc sw $10, 268501548($0) addi $10, $0, 0xfcfcfc sw $10, 268501552($0) addi $10, $0, 0xfcfcfc sw $10, 268501556($0) addi $10, $0, 0xfcfcfc sw $10, 268501560($0) addi $10, $0, 0xfcfcfc sw $10, 268501564($0) addi $10, $0, 0xfcfcfc sw $10, 268501568($0) addi $10, $0, 0xfcfcfc sw $10, 268501572($0) addi $10, $0, 0xfcfcfc sw $10, 268501576($0) addi $10, $0, 0xfcfcfc sw $10, 268501580($0) addi $10, $0, 0xfcfcfc sw $10, 268501584($0) addi $10, $0, 0xfcfcfc sw $10, 268501588($0) addi $10, $0, 0xfcfcfc sw $10, 268501592($0) addi $10, $0, 0xfcfcfc sw $10, 268501596($0) addi $10, $0, 0xfcfcfc sw $10, 268501600($0) addi $10, $0, 0xfcfcfc sw $10, 268501604($0) addi $10, $0, 0xfcfcfc sw $10, 268501608($0) addi $10, $0, 0xfcfcfc sw $10, 268501612($0) addi $10, $0, 0xfcfcfc sw $10, 268501616($0) addi $10, $0, 0xfcfcfc sw $10, 268501620($0) addi $10, $0, 0xfdfdfd sw $10, 268501624($0) addi $10, $0, 0xfdfdfd sw $10, 268501628($0) addi $10, $0, 0xffffff sw $10, 268501632($0) addi $10, $0, 0xffffff sw $10, 268501636($0) addi $10, $0, 0xffffff sw $10, 268501640($0) addi $10, $0, 0xffffff sw $10, 268501644($0) addi $10, $0, 0xffffff sw $10, 268501648($0) addi $10, $0, 0xffffff sw $10, 268501652($0) addi $10, $0, 0xffffff sw $10, 268501656($0) addi $10, $0, 0xffffff sw $10, 268501660($0) addi $10, $0, 0xffffff sw $10, 268501664($0) addi $10, $0, 0xffffff sw $10, 268501668($0) addi $10, $0, 0xffffff sw $10, 268501672($0) addi $10, $0, 0xffffff sw $10, 268501676($0) addi $10, $0, 0xffffff sw $10, 268501680($0) addi $10, $0, 0xffffff sw $10, 268501684($0) addi $10, $0, 0xffffff sw $10, 268501688($0) addi $10, $0, 0xffffff sw $10, 268501692($0) addi $10, $0, 0xffffff sw $10, 268501696($0) addi $10, $0, 0xffffff sw $10, 268501700($0) addi $10, $0, 0xffffff sw $10, 268501704($0) addi $10, $0, 0xffffff sw $10, 268501708($0) addi $10, $0, 0xffffff sw $10, 268501712($0) addi $10, $0, 0xffffff sw $10, 268501716($0) addi $10, $0, 0xffffff sw $10, 268501720($0) addi $10, $0, 0xffffff sw $10, 268501724($0) addi $10, $0, 0xffffff sw $10, 268501728($0) addi $10, $0, 0xffffff sw $10, 268501732($0) addi $10, $0, 0xffffff sw $10, 268501736($0) addi $10, $0, 0xffffff sw $10, 268501740($0) addi $10, $0, 0xffffff sw $10, 268501744($0) addi $10, $0, 0xffffff sw $10, 268501748($0) addi $10, $0, 0xffffff sw $10, 268501752($0) addi $10, $0, 0x00d800 sw $10, 268501756($0) addi $10, $0, 0x00d800 sw $10, 268501760($0) addi $10, $0, 0xfbfbfb sw $10, 268501764($0) addi $10, $0, 0xffb000 sw $10, 268501768($0) addi $10, $0, 0xffb000 sw $10, 268501772($0) addi $10, $0, 0xffb000 sw $10, 268501776($0) addi $10, $0, 0xffb000 sw $10, 268501780($0) addi $10, $0, 0xffb000 sw $10, 268501784($0) addi $10, $0, 0xffb000 sw $10, 268501788($0) addi $10, $0, 0xffb000 sw $10, 268501792($0) addi $10, $0, 0xffb000 sw $10, 268501796($0) addi $10, $0, 0xffb000 sw $10, 268501800($0) addi $10, $0, 0xffb000 sw $10, 268501804($0) addi $10, $0, 0xffb000 sw $10, 268501808($0) addi $10, $0, 0xffb000 sw $10, 268501812($0) addi $10, $0, 0xffb000 sw $10, 268501816($0) addi $10, $0, 0xffb000 sw $10, 268501820($0) addi $10, $0, 0xffb000 sw $10, 268501824($0) addi $10, $0, 0xffb000 sw $10, 268501828($0) addi $10, $0, 0xffb000 sw $10, 268501832($0) addi $10, $0, 0xffb000 sw $10, 268501836($0) addi $10, $0, 0xffb000 sw $10, 268501840($0) addi $10, $0, 0xffb000 sw $10, 268501844($0) addi $10, $0, 0xffb000 sw $10, 268501848($0) addi $10, $0, 0xffb000 sw $10, 268501852($0) addi $10, $0, 0xffb000 sw $10, 268501856($0) addi $10, $0, 0xffb000 sw $10, 268501860($0) addi $10, $0, 0xffb000 sw $10, 268501864($0) addi $10, $0, 0xffb000 sw $10, 268501868($0) addi $10, $0, 0xffb000 sw $10, 268501872($0) addi $10, $0, 0xffb000 sw $10, 268501876($0) addi $10, $0, 0xffb000 sw $10, 268501880($0) addi $10, $0, 0xffb000 sw $10, 268501884($0) addi $10, $0, 0xfbfbfb sw $10, 268501888($0) addi $10, $0, 0xffffff sw $10, 268501892($0) addi $10, $0, 0xffffff sw $10, 268501896($0) addi $10, $0, 0xffffff sw $10, 268501900($0) addi $10, $0, 0xffffff sw $10, 268501904($0) addi $10, $0, 0xffffff sw $10, 268501908($0) addi $10, $0, 0xffffff sw $10, 268501912($0) addi $10, $0, 0xffffff sw $10, 268501916($0) addi $10, $0, 0xffffff sw $10, 268501920($0) addi $10, $0, 0xffffff sw $10, 268501924($0) addi $10, $0, 0xffffff sw $10, 268501928($0) addi $10, $0, 0xffffff sw $10, 268501932($0) addi $10, $0, 0xffffff sw $10, 268501936($0) addi $10, $0, 0xffffff sw $10, 268501940($0) addi $10, $0, 0xffffff sw $10, 268501944($0) addi $10, $0, 0xffffff sw $10, 268501948($0) addi $10, $0, 0xffffff sw $10, 268501952($0) addi $10, $0, 0xffffff sw $10, 268501956($0) addi $10, $0, 0xffffff sw $10, 268501960($0) addi $10, $0, 0xffffff sw $10, 268501964($0) addi $10, $0, 0xffffff sw $10, 268501968($0) addi $10, $0, 0xffffff sw $10, 268501972($0) addi $10, $0, 0xffffff sw $10, 268501976($0) addi $10, $0, 0xffffff sw $10, 268501980($0) addi $10, $0, 0xffffff sw $10, 268501984($0) addi $10, $0, 0xffffff sw $10, 268501988($0) addi $10, $0, 0xffffff sw $10, 268501992($0) addi $10, $0, 0xffffff sw $10, 268501996($0) addi $10, $0, 0xffffff sw $10, 268502000($0) addi $10, $0, 0xffffff sw $10, 268502004($0) addi $10, $0, 0xffffff sw $10, 268502008($0) addi $10, $0, 0x00d800 sw $10, 268502012($0) addi $10, $0, 0x00d800 sw $10, 268502016($0) addi $10, $0, 0xf6f6f6 sw $10, 268502020($0) addi $10, $0, 0xffb000 sw $10, 268502024($0) addi $10, $0, 0xffb000 sw $10, 268502028($0) addi $10, $0, 0xffb000 sw $10, 268502032($0) addi $10, $0, 0xffb000 sw $10, 268502036($0) addi $10, $0, 0xffb000 sw $10, 268502040($0) addi $10, $0, 0xffb000 sw $10, 268502044($0) addi $10, $0, 0xffb000 sw $10, 268502048($0) addi $10, $0, 0xffb000 sw $10, 268502052($0) addi $10, $0, 0xffb000 sw $10, 268502056($0) addi $10, $0, 0xffb000 sw $10, 268502060($0) addi $10, $0, 0xffb000 sw $10, 268502064($0) addi $10, $0, 0xffb000 sw $10, 268502068($0) addi $10, $0, 0xffb000 sw $10, 268502072($0) addi $10, $0, 0xffb000 sw $10, 268502076($0) addi $10, $0, 0xffb000 sw $10, 268502080($0) addi $10, $0, 0xffb000 sw $10, 268502084($0) addi $10, $0, 0xffb000 sw $10, 268502088($0) addi $10, $0, 0xffb000 sw $10, 268502092($0) addi $10, $0, 0xffb000 sw $10, 268502096($0) addi $10, $0, 0xffb000 sw $10, 268502100($0) addi $10, $0, 0xffb000 sw $10, 268502104($0) addi $10, $0, 0xffb000 sw $10, 268502108($0) addi $10, $0, 0xffb000 sw $10, 268502112($0) addi $10, $0, 0xffb000 sw $10, 268502116($0) addi $10, $0, 0xffb000 sw $10, 268502120($0) addi $10, $0, 0xffb000 sw $10, 268502124($0) addi $10, $0, 0xffb000 sw $10, 268502128($0) addi $10, $0, 0xffb000 sw $10, 268502132($0) addi $10, $0, 0xffb000 sw $10, 268502136($0) addi $10, $0, 0xffb000 sw $10, 268502140($0) addi $10, $0, 0xf5f5f5 sw $10, 268502144($0) addi $10, $0, 0xfefefe sw $10, 268502148($0) addi $10, $0, 0xffffff sw $10, 268502152($0) addi $10, $0, 0x3d85c6 sw $10, 268502156($0) addi $10, $0, 0x3d85c6 sw $10, 268502160($0) addi $10, $0, 0x000000 sw $10, 268502164($0) addi $10, $0, 0x081119 sw $10, 268502168($0) addi $10, $0, 0xffffff sw $10, 268502172($0) addi $10, $0, 0xffffff sw $10, 268502176($0) addi $10, $0, 0xffffff sw $10, 268502180($0) addi $10, $0, 0xb7b7b7 sw $10, 268502184($0) addi $10, $0, 0xb7b7b7 sw $10, 268502188($0) addi $10, $0, 0x171717 sw $10, 268502192($0) addi $10, $0, 0x171717 sw $10, 268502196($0) addi $10, $0, 0x171717 sw $10, 268502200($0) addi $10, $0, 0x171717 sw $10, 268502204($0) addi $10, $0, 0xb7b7b7 sw $10, 268502208($0) addi $10, $0, 0xb7b7b7 sw $10, 268502212($0) addi $10, $0, 0xb7b7b7 sw $10, 268502216($0) addi $10, $0, 0xb7b7b7 sw $10, 268502220($0) addi $10, $0, 0xb7b7b7 sw $10, 268502224($0) addi $10, $0, 0x000000 sw $10, 268502228($0) addi $10, $0, 0x000000 sw $10, 268502232($0) addi $10, $0, 0xb7b7b7 sw $10, 268502236($0) addi $10, $0, 0xb7b7b7 sw $10, 268502240($0) addi $10, $0, 0xb7b7b7 sw $10, 268502244($0) addi $10, $0, 0xb7b7b7 sw $10, 268502248($0) addi $10, $0, 0xb7b7b7 sw $10, 268502252($0) addi $10, $0, 0xb7b7b7 sw $10, 268502256($0) addi $10, $0, 0xffffff sw $10, 268502260($0) addi $10, $0, 0xffffff sw $10, 268502264($0) addi $10, $0, 0x00d800 sw $10, 268502268($0) addi $10, $0, 0x00d700 sw $10, 268502272($0) addi $10, $0, 0xf3f3f3 sw $10, 268502276($0) addi $10, $0, 0xffb000 sw $10, 268502280($0) addi $10, $0, 0xffb000 sw $10, 268502284($0) addi $10, $0, 0x000000 sw $10, 268502288($0) addi $10, $0, 0xffb000 sw $10, 268502292($0) addi $10, $0, 0xffb000 sw $10, 268502296($0) addi $10, $0, 0x000000 sw $10, 268502300($0) addi $10, $0, 0xffb000 sw $10, 268502304($0) addi $10, $0, 0xffb000 sw $10, 268502308($0) addi $10, $0, 0xffb000 sw $10, 268502312($0) addi $10, $0, 0xffb000 sw $10, 268502316($0) addi $10, $0, 0xffb000 sw $10, 268502320($0) addi $10, $0, 0xffb000 sw $10, 268502324($0) addi $10, $0, 0xffb000 sw $10, 268502328($0) addi $10, $0, 0xffb000 sw $10, 268502332($0) addi $10, $0, 0xffb000 sw $10, 268502336($0) addi $10, $0, 0xffb000 sw $10, 268502340($0) addi $10, $0, 0x000000 sw $10, 268502344($0) addi $10, $0, 0xffb000 sw $10, 268502348($0) addi $10, $0, 0xffb000 sw $10, 268502352($0) addi $10, $0, 0xffb000 sw $10, 268502356($0) addi $10, $0, 0xffb000 sw $10, 268502360($0) addi $10, $0, 0xffb000 sw $10, 268502364($0) addi $10, $0, 0xffb000 sw $10, 268502368($0) addi $10, $0, 0xffb000 sw $10, 268502372($0) addi $10, $0, 0xffb000 sw $10, 268502376($0) addi $10, $0, 0xffb000 sw $10, 268502380($0) addi $10, $0, 0xffb000 sw $10, 268502384($0) addi $10, $0, 0xffb000 sw $10, 268502388($0) addi $10, $0, 0xffb000 sw $10, 268502392($0) addi $10, $0, 0xffb000 sw $10, 268502396($0) addi $10, $0, 0xf1f1f1 sw $10, 268502400($0) addi $10, $0, 0xfdfdfd sw $10, 268502404($0) addi $10, $0, 0x3d85c6 sw $10, 268502408($0) addi $10, $0, 0x3d85c6 sw $10, 268502412($0) addi $10, $0, 0x000000 sw $10, 268502416($0) addi $10, $0, 0x3d85c6 sw $10, 268502420($0) addi $10, $0, 0x000000 sw $10, 268502424($0) addi $10, $0, 0x050a10 sw $10, 268502428($0) addi $10, $0, 0xffffff sw $10, 268502432($0) addi $10, $0, 0xffffff sw $10, 268502436($0) addi $10, $0, 0xb7b7b7 sw $10, 268502440($0) addi $10, $0, 0xb7b7b7 sw $10, 268502444($0) addi $10, $0, 0x000000 sw $10, 268502448($0) addi $10, $0, 0x171717 sw $10, 268502452($0) addi $10, $0, 0x171717 sw $10, 268502456($0) addi $10, $0, 0x171717 sw $10, 268502460($0) addi $10, $0, 0xb7b7b7 sw $10, 268502464($0) addi $10, $0, 0xb7b7b7 sw $10, 268502468($0) addi $10, $0, 0xb7b7b7 sw $10, 268502472($0) addi $10, $0, 0xb7b7b7 sw $10, 268502476($0) addi $10, $0, 0xb7b7b7 sw $10, 268502480($0) addi $10, $0, 0xb7b7b7 sw $10, 268502484($0) addi $10, $0, 0xb7b7b7 sw $10, 268502488($0) addi $10, $0, 0xb7b7b7 sw $10, 268502492($0) addi $10, $0, 0x000000 sw $10, 268502496($0) addi $10, $0, 0xb7b7b7 sw $10, 268502500($0) addi $10, $0, 0xb7b7b7 sw $10, 268502504($0) addi $10, $0, 0xb7b7b7 sw $10, 268502508($0) addi $10, $0, 0xb7b7b7 sw $10, 268502512($0) addi $10, $0, 0xffffff sw $10, 268502516($0) addi $10, $0, 0xffffff sw $10, 268502520($0) addi $10, $0, 0x00d800 sw $10, 268502524($0) addi $10, $0, 0x00d700 sw $10, 268502528($0) addi $10, $0, 0xf3f3f3 sw $10, 268502532($0) addi $10, $0, 0xffb000 sw $10, 268502536($0) addi $10, $0, 0xffb000 sw $10, 268502540($0) addi $10, $0, 0x000000 sw $10, 268502544($0) addi $10, $0, 0x000000 sw $10, 268502548($0) addi $10, $0, 0xffb000 sw $10, 268502552($0) addi $10, $0, 0x000000 sw $10, 268502556($0) addi $10, $0, 0xffb000 sw $10, 268502560($0) addi $10, $0, 0x000000 sw $10, 268502564($0) addi $10, $0, 0xffb000 sw $10, 268502568($0) addi $10, $0, 0x604200 sw $10, 268502572($0) addi $10, $0, 0x2c1e00 sw $10, 268502576($0) addi $10, $0, 0x000000 sw $10, 268502580($0) addi $10, $0, 0x281c00 sw $10, 268502584($0) addi $10, $0, 0x000000 sw $10, 268502588($0) addi $10, $0, 0x805800 sw $10, 268502592($0) addi $10, $0, 0xffb000 sw $10, 268502596($0) addi $10, $0, 0x000000 sw $10, 268502600($0) addi $10, $0, 0x000000 sw $10, 268502604($0) addi $10, $0, 0xffb000 sw $10, 268502608($0) addi $10, $0, 0xffb000 sw $10, 268502612($0) addi $10, $0, 0x000000 sw $10, 268502616($0) addi $10, $0, 0x000000 sw $10, 268502620($0) addi $10, $0, 0xffb000 sw $10, 268502624($0) addi $10, $0, 0x906300 sw $10, 268502628($0) addi $10, $0, 0x000000 sw $10, 268502632($0) addi $10, $0, 0x442f00 sw $10, 268502636($0) addi $10, $0, 0x040300 sw $10, 268502640($0) addi $10, $0, 0x000000 sw $10, 268502644($0) addi $10, $0, 0xffb000 sw $10, 268502648($0) addi $10, $0, 0xffb000 sw $10, 268502652($0) addi $10, $0, 0xf1f1f1 sw $10, 268502656($0) addi $10, $0, 0x3d85c6 sw $10, 268502660($0) addi $10, $0, 0x3d85c6 sw $10, 268502664($0) addi $10, $0, 0x3d85c6 sw $10, 268502668($0) addi $10, $0, 0x000000 sw $10, 268502672($0) addi $10, $0, 0x3d85c6 sw $10, 268502676($0) addi $10, $0, 0x2c608f sw $10, 268502680($0) addi $10, $0, 0x000000 sw $10, 268502684($0) addi $10, $0, 0x3d85c6 sw $10, 268502688($0) addi $10, $0, 0xffffff sw $10, 268502692($0) addi $10, $0, 0xb7b7b7 sw $10, 268502696($0) addi $10, $0, 0xb7b7b7 sw $10, 268502700($0) addi $10, $0, 0x000000 sw $10, 268502704($0) addi $10, $0, 0xb7b7b7 sw $10, 268502708($0) addi $10, $0, 0xb7b7b7 sw $10, 268502712($0) addi $10, $0, 0xb7b7b7 sw $10, 268502716($0) addi $10, $0, 0xb7b7b7 sw $10, 268502720($0) addi $10, $0, 0x000000 sw $10, 268502724($0) addi $10, $0, 0xb7b7b7 sw $10, 268502728($0) addi $10, $0, 0x000000 sw $10, 268502732($0) addi $10, $0, 0xb7b7b7 sw $10, 268502736($0) addi $10, $0, 0x454545 sw $10, 268502740($0) addi $10, $0, 0x000000 sw $10, 268502744($0) addi $10, $0, 0xb7b7b7 sw $10, 268502748($0) addi $10, $0, 0x000000 sw $10, 268502752($0) addi $10, $0, 0x000000 sw $10, 268502756($0) addi $10, $0, 0x000000 sw $10, 268502760($0) addi $10, $0, 0xb7b7b7 sw $10, 268502764($0) addi $10, $0, 0xb7b7b7 sw $10, 268502768($0) addi $10, $0, 0xffffff sw $10, 268502772($0) addi $10, $0, 0xffffff sw $10, 268502776($0) addi $10, $0, 0x00d800 sw $10, 268502780($0) addi $10, $0, 0x00d700 sw $10, 268502784($0) addi $10, $0, 0xf3f3f3 sw $10, 268502788($0) addi $10, $0, 0xffb000 sw $10, 268502792($0) addi $10, $0, 0xffb000 sw $10, 268502796($0) addi $10, $0, 0x000000 sw $10, 268502800($0) addi $10, $0, 0x342400 sw $10, 268502804($0) addi $10, $0, 0xc78900 sw $10, 268502808($0) addi $10, $0, 0x000000 sw $10, 268502812($0) addi $10, $0, 0xffb000 sw $10, 268502816($0) addi $10, $0, 0x000000 sw $10, 268502820($0) addi $10, $0, 0xffb000 sw $10, 268502824($0) addi $10, $0, 0x604200 sw $10, 268502828($0) addi $10, $0, 0x000000 sw $10, 268502832($0) addi $10, $0, 0xffb000 sw $10, 268502836($0) addi $10, $0, 0x000000 sw $10, 268502840($0) addi $10, $0, 0xffb000 sw $10, 268502844($0) addi $10, $0, 0x000000 sw $10, 268502848($0) addi $10, $0, 0xffb000 sw $10, 268502852($0) addi $10, $0, 0x000000 sw $10, 268502856($0) addi $10, $0, 0xffb000 sw $10, 268502860($0) addi $10, $0, 0x000000 sw $10, 268502864($0) addi $10, $0, 0xffb000 sw $10, 268502868($0) addi $10, $0, 0x302100 sw $10, 268502872($0) addi $10, $0, 0xffb000 sw $10, 268502876($0) addi $10, $0, 0x000000 sw $10, 268502880($0) addi $10, $0, 0x000000 sw $10, 268502884($0) addi $10, $0, 0xffb000 sw $10, 268502888($0) addi $10, $0, 0xffb000 sw $10, 268502892($0) addi $10, $0, 0x000000 sw $10, 268502896($0) addi $10, $0, 0xffb000 sw $10, 268502900($0) addi $10, $0, 0xffb000 sw $10, 268502904($0) addi $10, $0, 0xffb000 sw $10, 268502908($0) addi $10, $0, 0xf1f1f1 sw $10, 268502912($0) addi $10, $0, 0x3d85c6 sw $10, 268502916($0) addi $10, $0, 0x3d85c6 sw $10, 268502920($0) addi $10, $0, 0x3d85c6 sw $10, 268502924($0) addi $10, $0, 0x000000 sw $10, 268502928($0) addi $10, $0, 0x000000 sw $10, 268502932($0) addi $10, $0, 0x000000 sw $10, 268502936($0) addi $10, $0, 0x000000 sw $10, 268502940($0) addi $10, $0, 0x3d85c6 sw $10, 268502944($0) addi $10, $0, 0xffffff sw $10, 268502948($0) addi $10, $0, 0xb7b7b7 sw $10, 268502952($0) addi $10, $0, 0xb7b7b7 sw $10, 268502956($0) addi $10, $0, 0x000000 sw $10, 268502960($0) addi $10, $0, 0x000000 sw $10, 268502964($0) addi $10, $0, 0x000000 sw $10, 268502968($0) addi $10, $0, 0x454545 sw $10, 268502972($0) addi $10, $0, 0xb7b7b7 sw $10, 268502976($0) addi $10, $0, 0xa9a9a9 sw $10, 268502980($0) addi $10, $0, 0x000000 sw $10, 268502984($0) addi $10, $0, 0x030303 sw $10, 268502988($0) addi $10, $0, 0xb7b7b7 sw $10, 268502992($0) addi $10, $0, 0x454545 sw $10, 268502996($0) addi $10, $0, 0x000000 sw $10, 268503000($0) addi $10, $0, 0xb7b7b7 sw $10, 268503004($0) addi $10, $0, 0x000000 sw $10, 268503008($0) addi $10, $0, 0xb7b7b7 sw $10, 268503012($0) addi $10, $0, 0xb7b7b7 sw $10, 268503016($0) addi $10, $0, 0xb7b7b7 sw $10, 268503020($0) addi $10, $0, 0xb7b7b7 sw $10, 268503024($0) addi $10, $0, 0xffffff sw $10, 268503028($0) addi $10, $0, 0xffffff sw $10, 268503032($0) addi $10, $0, 0x00d800 sw $10, 268503036($0) addi $10, $0, 0x00d700 sw $10, 268503040($0) addi $10, $0, 0xf3f3f3 sw $10, 268503044($0) addi $10, $0, 0xffb000 sw $10, 268503048($0) addi $10, $0, 0xffb000 sw $10, 268503052($0) addi $10, $0, 0x000000 sw $10, 268503056($0) addi $10, $0, 0xffb000 sw $10, 268503060($0) addi $10, $0, 0x000000 sw $10, 268503064($0) addi $10, $0, 0x000000 sw $10, 268503068($0) addi $10, $0, 0xffb000 sw $10, 268503072($0) addi $10, $0, 0x000000 sw $10, 268503076($0) addi $10, $0, 0xffb000 sw $10, 268503080($0) addi $10, $0, 0x604200 sw $10, 268503084($0) addi $10, $0, 0x000000 sw $10, 268503088($0) addi $10, $0, 0xffb000 sw $10, 268503092($0) addi $10, $0, 0x000000 sw $10, 268503096($0) addi $10, $0, 0xffb000 sw $10, 268503100($0) addi $10, $0, 0x000000 sw $10, 268503104($0) addi $10, $0, 0xffb000 sw $10, 268503108($0) addi $10, $0, 0x000000 sw $10, 268503112($0) addi $10, $0, 0xffb000 sw $10, 268503116($0) addi $10, $0, 0x000000 sw $10, 268503120($0) addi $10, $0, 0xfbad00 sw $10, 268503124($0) addi $10, $0, 0x483200 sw $10, 268503128($0) addi $10, $0, 0xffb000 sw $10, 268503132($0) addi $10, $0, 0xffb000 sw $10, 268503136($0) addi $10, $0, 0x000000 sw $10, 268503140($0) addi $10, $0, 0xffb000 sw $10, 268503144($0) addi $10, $0, 0xffb000 sw $10, 268503148($0) addi $10, $0, 0xffb000 sw $10, 268503152($0) addi $10, $0, 0x000000 sw $10, 268503156($0) addi $10, $0, 0xffb000 sw $10, 268503160($0) addi $10, $0, 0xffb000 sw $10, 268503164($0) addi $10, $0, 0xf1f1f1 sw $10, 268503168($0) addi $10, $0, 0x498dca sw $10, 268503172($0) addi $10, $0, 0x3d85c6 sw $10, 268503176($0) addi $10, $0, 0x3d85c6 sw $10, 268503180($0) addi $10, $0, 0x3d85c6 sw $10, 268503184($0) addi $10, $0, 0x3d85c6 sw $10, 268503188($0) addi $10, $0, 0x000000 sw $10, 268503192($0) addi $10, $0, 0x193651 sw $10, 268503196($0) addi $10, $0, 0x3d85c6 sw $10, 268503200($0) addi $10, $0, 0xffffff sw $10, 268503204($0) addi $10, $0, 0xb7b7b7 sw $10, 268503208($0) addi $10, $0, 0xb7b7b7 sw $10, 268503212($0) addi $10, $0, 0x000000 sw $10, 268503216($0) addi $10, $0, 0xb7b7b7 sw $10, 268503220($0) addi $10, $0, 0xb7b7b7 sw $10, 268503224($0) addi $10, $0, 0xb7b7b7 sw $10, 268503228($0) addi $10, $0, 0xb7b7b7 sw $10, 268503232($0) addi $10, $0, 0x4b4b4b sw $10, 268503236($0) addi $10, $0, 0x000000 sw $10, 268503240($0) addi $10, $0, 0x000000 sw $10, 268503244($0) addi $10, $0, 0xb7b7b7 sw $10, 268503248($0) addi $10, $0, 0x454545 sw $10, 268503252($0) addi $10, $0, 0x000000 sw $10, 268503256($0) addi $10, $0, 0xb7b7b7 sw $10, 268503260($0) addi $10, $0, 0x000000 sw $10, 268503264($0) addi $10, $0, 0xb7b7b7 sw $10, 268503268($0) addi $10, $0, 0xb7b7b7 sw $10, 268503272($0) addi $10, $0, 0xb7b7b7 sw $10, 268503276($0) addi $10, $0, 0xb7b7b7 sw $10, 268503280($0) addi $10, $0, 0xffffff sw $10, 268503284($0) addi $10, $0, 0xffffff sw $10, 268503288($0) addi $10, $0, 0x00d800 sw $10, 268503292($0) addi $10, $0, 0x00d700 sw $10, 268503296($0) addi $10, $0, 0xf3f3f3 sw $10, 268503300($0) addi $10, $0, 0xffb000 sw $10, 268503304($0) addi $10, $0, 0xffb000 sw $10, 268503308($0) addi $10, $0, 0x000000 sw $10, 268503312($0) addi $10, $0, 0xffb000 sw $10, 268503316($0) addi $10, $0, 0xffb000 sw $10, 268503320($0) addi $10, $0, 0x000000 sw $10, 268503324($0) addi $10, $0, 0xffb000 sw $10, 268503328($0) addi $10, $0, 0x000000 sw $10, 268503332($0) addi $10, $0, 0x000000 sw $10, 268503336($0) addi $10, $0, 0x604200 sw $10, 268503340($0) addi $10, $0, 0x000000 sw $10, 268503344($0) addi $10, $0, 0xffb000 sw $10, 268503348($0) addi $10, $0, 0x000000 sw $10, 268503352($0) addi $10, $0, 0xffb000 sw $10, 268503356($0) addi $10, $0, 0x000000 sw $10, 268503360($0) addi $10, $0, 0xffb000 sw $10, 268503364($0) addi $10, $0, 0x000000 sw $10, 268503368($0) addi $10, $0, 0x000000 sw $10, 268503372($0) addi $10, $0, 0xffb000 sw $10, 268503376($0) addi $10, $0, 0xffb000 sw $10, 268503380($0) addi $10, $0, 0x000000 sw $10, 268503384($0) addi $10, $0, 0x000000 sw $10, 268503388($0) addi $10, $0, 0xf7aa00 sw $10, 268503392($0) addi $10, $0, 0x000000 sw $10, 268503396($0) addi $10, $0, 0xffb000 sw $10, 268503400($0) addi $10, $0, 0xffb000 sw $10, 268503404($0) addi $10, $0, 0x000000 sw $10, 268503408($0) addi $10, $0, 0x000000 sw $10, 268503412($0) addi $10, $0, 0xffb000 sw $10, 268503416($0) addi $10, $0, 0xffb000 sw $10, 268503420($0) addi $10, $0, 0xf1f1f1 sw $10, 268503424($0) addi $10, $0, 0xfdfdfd sw $10, 268503428($0) addi $10, $0, 0x3d85c6 sw $10, 268503432($0) addi $10, $0, 0x3d85c6 sw $10, 268503436($0) addi $10, $0, 0x000000 sw $10, 268503440($0) addi $10, $0, 0x000000 sw $10, 268503444($0) addi $10, $0, 0x000000 sw $10, 268503448($0) addi $10, $0, 0x3d85c6 sw $10, 268503452($0) addi $10, $0, 0xffffff sw $10, 268503456($0) addi $10, $0, 0xffffff sw $10, 268503460($0) addi $10, $0, 0xb7b7b7 sw $10, 268503464($0) addi $10, $0, 0xb7b7b7 sw $10, 268503468($0) addi $10, $0, 0x000000 sw $10, 268503472($0) addi $10, $0, 0x000000 sw $10, 268503476($0) addi $10, $0, 0x000000 sw $10, 268503480($0) addi $10, $0, 0x000000 sw $10, 268503484($0) addi $10, $0, 0xb7b7b7 sw $10, 268503488($0) addi $10, $0, 0x000000 sw $10, 268503492($0) addi $10, $0, 0xb7b7b7 sw $10, 268503496($0) addi $10, $0, 0x000000 sw $10, 268503500($0) addi $10, $0, 0xb7b7b7 sw $10, 268503504($0) addi $10, $0, 0x454545 sw $10, 268503508($0) addi $10, $0, 0x000000 sw $10, 268503512($0) addi $10, $0, 0xb7b7b7 sw $10, 268503516($0) addi $10, $0, 0x000000 sw $10, 268503520($0) addi $10, $0, 0x000000 sw $10, 268503524($0) addi $10, $0, 0x000000 sw $10, 268503528($0) addi $10, $0, 0xb7b7b7 sw $10, 268503532($0) addi $10, $0, 0xb7b7b7 sw $10, 268503536($0) addi $10, $0, 0xffffff sw $10, 268503540($0) addi $10, $0, 0xffffff sw $10, 268503544($0) addi $10, $0, 0x00d800 sw $10, 268503548($0) addi $10, $0, 0x00d700 sw $10, 268503552($0) addi $10, $0, 0xf3f3f3 sw $10, 268503556($0) addi $10, $0, 0xffb000 sw $10, 268503560($0) addi $10, $0, 0xffb000 sw $10, 268503564($0) addi $10, $0, 0xffb000 sw $10, 268503568($0) addi $10, $0, 0xffb000 sw $10, 268503572($0) addi $10, $0, 0xffb000 sw $10, 268503576($0) addi $10, $0, 0xffb000 sw $10, 268503580($0) addi $10, $0, 0xffb000 sw $10, 268503584($0) addi $10, $0, 0xffb000 sw $10, 268503588($0) addi $10, $0, 0xffb000 sw $10, 268503592($0) addi $10, $0, 0xffb000 sw $10, 268503596($0) addi $10, $0, 0xffb000 sw $10, 268503600($0) addi $10, $0, 0xffb000 sw $10, 268503604($0) addi $10, $0, 0xffb000 sw $10, 268503608($0) addi $10, $0, 0xffb000 sw $10, 268503612($0) addi $10, $0, 0xffb000 sw $10, 268503616($0) addi $10, $0, 0xffb000 sw $10, 268503620($0) addi $10, $0, 0xffb000 sw $10, 268503624($0) addi $10, $0, 0xffb000 sw $10, 268503628($0) addi $10, $0, 0xffb000 sw $10, 268503632($0) addi $10, $0, 0xffb000 sw $10, 268503636($0) addi $10, $0, 0xffb000 sw $10, 268503640($0) addi $10, $0, 0xffb000 sw $10, 268503644($0) addi $10, $0, 0xffb000 sw $10, 268503648($0) addi $10, $0, 0xffb000 sw $10, 268503652($0) addi $10, $0, 0xffb000 sw $10, 268503656($0) addi $10, $0, 0xffb000 sw $10, 268503660($0) addi $10, $0, 0xffb000 sw $10, 268503664($0) addi $10, $0, 0xffb000 sw $10, 268503668($0) addi $10, $0, 0xffb000 sw $10, 268503672($0) addi $10, $0, 0xffb000 sw $10, 268503676($0) addi $10, $0, 0xf1f1f1 sw $10, 268503680($0) addi $10, $0, 0xfdfdfd sw $10, 268503684($0) addi $10, $0, 0xffffff sw $10, 268503688($0) addi $10, $0, 0xffffff sw $10, 268503692($0) addi $10, $0, 0x5594cd sw $10, 268503696($0) addi $10, $0, 0x3d85c6 sw $10, 268503700($0) addi $10, $0, 0xffffff sw $10, 268503704($0) addi $10, $0, 0xffffff sw $10, 268503708($0) addi $10, $0, 0xffffff sw $10, 268503712($0) addi $10, $0, 0xffffff sw $10, 268503716($0) addi $10, $0, 0xb7b7b7 sw $10, 268503720($0) addi $10, $0, 0xb7b7b7 sw $10, 268503724($0) addi $10, $0, 0xb7b7b7 sw $10, 268503728($0) addi $10, $0, 0xb7b7b7 sw $10, 268503732($0) addi $10, $0, 0xb7b7b7 sw $10, 268503736($0) addi $10, $0, 0xb7b7b7 sw $10, 268503740($0) addi $10, $0, 0xb7b7b7 sw $10, 268503744($0) addi $10, $0, 0xb7b7b7 sw $10, 268503748($0) addi $10, $0, 0xb7b7b7 sw $10, 268503752($0) addi $10, $0, 0xb7b7b7 sw $10, 268503756($0) addi $10, $0, 0xb7b7b7 sw $10, 268503760($0) addi $10, $0, 0xb7b7b7 sw $10, 268503764($0) addi $10, $0, 0xb7b7b7 sw $10, 268503768($0) addi $10, $0, 0xb7b7b7 sw $10, 268503772($0) addi $10, $0, 0xb7b7b7 sw $10, 268503776($0) addi $10, $0, 0xb7b7b7 sw $10, 268503780($0) addi $10, $0, 0xb7b7b7 sw $10, 268503784($0) addi $10, $0, 0xb7b7b7 sw $10, 268503788($0) addi $10, $0, 0xb7b7b7 sw $10, 268503792($0) addi $10, $0, 0xffffff sw $10, 268503796($0) addi $10, $0, 0xffffff sw $10, 268503800($0) addi $10, $0, 0x00d800 sw $10, 268503804($0) addi $10, $0, 0x00d700 sw $10, 268503808($0) addi $10, $0, 0xf6f6f6 sw $10, 268503812($0) addi $10, $0, 0xffb000 sw $10, 268503816($0) addi $10, $0, 0xffb000 sw $10, 268503820($0) addi $10, $0, 0xffb000 sw $10, 268503824($0) addi $10, $0, 0xffb000 sw $10, 268503828($0) addi $10, $0, 0xffb000 sw $10, 268503832($0) addi $10, $0, 0xffb000 sw $10, 268503836($0) addi $10, $0, 0xffb000 sw $10, 268503840($0) addi $10, $0, 0xffb000 sw $10, 268503844($0) addi $10, $0, 0xffb000 sw $10, 268503848($0) addi $10, $0, 0xffb000 sw $10, 268503852($0) addi $10, $0, 0xffb000 sw $10, 268503856($0) addi $10, $0, 0xffb000 sw $10, 268503860($0) addi $10, $0, 0xffb000 sw $10, 268503864($0) addi $10, $0, 0xffb000 sw $10, 268503868($0) addi $10, $0, 0xffb000 sw $10, 268503872($0) addi $10, $0, 0xffb000 sw $10, 268503876($0) addi $10, $0, 0xffb000 sw $10, 268503880($0) addi $10, $0, 0xffb000 sw $10, 268503884($0) addi $10, $0, 0xffb000 sw $10, 268503888($0) addi $10, $0, 0xffb000 sw $10, 268503892($0) addi $10, $0, 0xffb000 sw $10, 268503896($0) addi $10, $0, 0xffb000 sw $10, 268503900($0) addi $10, $0, 0xffb000 sw $10, 268503904($0) addi $10, $0, 0xffb000 sw $10, 268503908($0) addi $10, $0, 0xffb000 sw $10, 268503912($0) addi $10, $0, 0xffb000 sw $10, 268503916($0) addi $10, $0, 0xffb000 sw $10, 268503920($0) addi $10, $0, 0xffb000 sw $10, 268503924($0) addi $10, $0, 0xffb000 sw $10, 268503928($0) addi $10, $0, 0xffb000 sw $10, 268503932($0) addi $10, $0, 0xf4f4f4 sw $10, 268503936($0) addi $10, $0, 0xfefefe sw $10, 268503940($0) addi $10, $0, 0xffffff sw $10, 268503944($0) addi $10, $0, 0xffffff sw $10, 268503948($0) addi $10, $0, 0xffffff sw $10, 268503952($0) addi $10, $0, 0xffffff sw $10, 268503956($0) addi $10, $0, 0xffffff sw $10, 268503960($0) addi $10, $0, 0xffffff sw $10, 268503964($0) addi $10, $0, 0xffffff sw $10, 268503968($0) addi $10, $0, 0xffffff sw $10, 268503972($0) addi $10, $0, 0xffffff sw $10, 268503976($0) addi $10, $0, 0xffffff sw $10, 268503980($0) addi $10, $0, 0xffffff sw $10, 268503984($0) addi $10, $0, 0xffffff sw $10, 268503988($0) addi $10, $0, 0xffffff sw $10, 268503992($0) addi $10, $0, 0xffffff sw $10, 268503996($0) addi $10, $0, 0xffffff sw $10, 268504000($0) addi $10, $0, 0xffffff sw $10, 268504004($0) addi $10, $0, 0xffffff sw $10, 268504008($0) addi $10, $0, 0xffffff sw $10, 268504012($0) addi $10, $0, 0xffffff sw $10, 268504016($0) addi $10, $0, 0xffffff sw $10, 268504020($0) addi $10, $0, 0xffffff sw $10, 268504024($0) addi $10, $0, 0xffffff sw $10, 268504028($0) addi $10, $0, 0xffffff sw $10, 268504032($0) addi $10, $0, 0xffffff sw $10, 268504036($0) addi $10, $0, 0xffffff sw $10, 268504040($0) addi $10, $0, 0xffffff sw $10, 268504044($0) addi $10, $0, 0xffffff sw $10, 268504048($0) addi $10, $0, 0xffffff sw $10, 268504052($0) addi $10, $0, 0xffffff sw $10, 268504056($0) addi $10, $0, 0x00d800 sw $10, 268504060($0) addi $10, $0, 0x00d800 sw $10, 268504064($0) addi $10, $0, 0xfbfbfb sw $10, 268504068($0) addi $10, $0, 0xf3f3f3 sw $10, 268504072($0) addi $10, $0, 0xededed sw $10, 268504076($0) addi $10, $0, 0xececec sw $10, 268504080($0) addi $10, $0, 0xececec sw $10, 268504084($0) addi $10, $0, 0xececec sw $10, 268504088($0) addi $10, $0, 0xececec sw $10, 268504092($0) addi $10, $0, 0xececec sw $10, 268504096($0) addi $10, $0, 0xececec sw $10, 268504100($0) addi $10, $0, 0xececec sw $10, 268504104($0) addi $10, $0, 0xececec sw $10, 268504108($0) addi $10, $0, 0xececec sw $10, 268504112($0) addi $10, $0, 0xececec sw $10, 268504116($0) addi $10, $0, 0xececec sw $10, 268504120($0) addi $10, $0, 0xececec sw $10, 268504124($0) addi $10, $0, 0xececec sw $10, 268504128($0) addi $10, $0, 0xececec sw $10, 268504132($0) addi $10, $0, 0xececec sw $10, 268504136($0) addi $10, $0, 0xececec sw $10, 268504140($0) addi $10, $0, 0xececec sw $10, 268504144($0) addi $10, $0, 0xececec sw $10, 268504148($0) addi $10, $0, 0xececec sw $10, 268504152($0) addi $10, $0, 0xececec sw $10, 268504156($0) addi $10, $0, 0xececec sw $10, 268504160($0) addi $10, $0, 0xececec sw $10, 268504164($0) addi $10, $0, 0xececec sw $10, 268504168($0) addi $10, $0, 0xececec sw $10, 268504172($0) addi $10, $0, 0xececec sw $10, 268504176($0) addi $10, $0, 0xececec sw $10, 268504180($0) addi $10, $0, 0xededed sw $10, 268504184($0) addi $10, $0, 0xf3f3f3 sw $10, 268504188($0) addi $10, $0, 0xfafafa sw $10, 268504192($0) addi $10, $0, 0xffffff sw $10, 268504196($0) addi $10, $0, 0xffffff sw $10, 268504200($0) addi $10, $0, 0xffffff sw $10, 268504204($0) addi $10, $0, 0xffffff sw $10, 268504208($0) addi $10, $0, 0xffffff sw $10, 268504212($0) addi $10, $0, 0xffffff sw $10, 268504216($0) addi $10, $0, 0xffffff sw $10, 268504220($0) addi $10, $0, 0xffffff sw $10, 268504224($0) addi $10, $0, 0xffffff sw $10, 268504228($0) addi $10, $0, 0xffffff sw $10, 268504232($0) addi $10, $0, 0xffffff sw $10, 268504236($0) addi $10, $0, 0xffffff sw $10, 268504240($0) addi $10, $0, 0xffffff sw $10, 268504244($0) addi $10, $0, 0xffffff sw $10, 268504248($0) addi $10, $0, 0xffffff sw $10, 268504252($0) addi $10, $0, 0xffffff sw $10, 268504256($0) addi $10, $0, 0xffffff sw $10, 268504260($0) addi $10, $0, 0xffffff sw $10, 268504264($0) addi $10, $0, 0xffffff sw $10, 268504268($0) addi $10, $0, 0xffffff sw $10, 268504272($0) addi $10, $0, 0xffffff sw $10, 268504276($0) addi $10, $0, 0xffffff sw $10, 268504280($0) addi $10, $0, 0xffffff sw $10, 268504284($0) addi $10, $0, 0xffffff sw $10, 268504288($0) addi $10, $0, 0xffffff sw $10, 268504292($0) addi $10, $0, 0xffffff sw $10, 268504296($0) addi $10, $0, 0xffffff sw $10, 268504300($0) addi $10, $0, 0xffffff sw $10, 268504304($0) addi $10, $0, 0xffffff sw $10, 268504308($0) addi $10, $0, 0xffffff sw $10, 268504312($0) addi $10, $0, 0x00d800 sw $10, 268504316($0) addi $10, $0, 0x00d800 sw $10, 268504320($0) addi $10, $0, 0xffffff sw $10, 268504324($0) addi $10, $0, 0xfdfdfd sw $10, 268504328($0) addi $10, $0, 0xfcfcfc sw $10, 268504332($0) addi $10, $0, 0xfbfbfb sw $10, 268504336($0) addi $10, $0, 0xfbfbfb sw $10, 268504340($0) addi $10, $0, 0xfbfbfb sw $10, 268504344($0) addi $10, $0, 0xfbfbfb sw $10, 268504348($0) addi $10, $0, 0xfbfbfb sw $10, 268504352($0) addi $10, $0, 0xfbfbfb sw $10, 268504356($0) addi $10, $0, 0xfbfbfb sw $10, 268504360($0) addi $10, $0, 0xfbfbfb sw $10, 268504364($0) addi $10, $0, 0xfbfbfb sw $10, 268504368($0) addi $10, $0, 0xfbfbfb sw $10, 268504372($0) addi $10, $0, 0xfbfbfb sw $10, 268504376($0) addi $10, $0, 0xfbfbfb sw $10, 268504380($0) addi $10, $0, 0xfbfbfb sw $10, 268504384($0) addi $10, $0, 0xfbfbfb sw $10, 268504388($0) addi $10, $0, 0xfbfbfb sw $10, 268504392($0) addi $10, $0, 0xfbfbfb sw $10, 268504396($0) addi $10, $0, 0xfbfbfb sw $10, 268504400($0) addi $10, $0, 0xfbfbfb sw $10, 268504404($0) addi $10, $0, 0xfbfbfb sw $10, 268504408($0) addi $10, $0, 0xfbfbfb sw $10, 268504412($0) addi $10, $0, 0xfbfbfb sw $10, 268504416($0) addi $10, $0, 0xfbfbfb sw $10, 268504420($0) addi $10, $0, 0xfbfbfb sw $10, 268504424($0) addi $10, $0, 0xfbfbfb sw $10, 268504428($0) addi $10, $0, 0xfbfbfb sw $10, 268504432($0) addi $10, $0, 0xfbfbfb sw $10, 268504436($0) addi $10, $0, 0xfbfbfb sw $10, 268504440($0) addi $10, $0, 0xfdfdfd sw $10, 268504444($0) addi $10, $0, 0xfefefe sw $10, 268504448($0) addi $10, $0, 0xffffff sw $10, 268504452($0) addi $10, $0, 0xffffff sw $10, 268504456($0) addi $10, $0, 0xffffff sw $10, 268504460($0) addi $10, $0, 0xffffff sw $10, 268504464($0) addi $10, $0, 0xffffff sw $10, 268504468($0) addi $10, $0, 0xffffff sw $10, 268504472($0) addi $10, $0, 0xffffff sw $10, 268504476($0) addi $10, $0, 0xffffff sw $10, 268504480($0) addi $10, $0, 0xffffff sw $10, 268504484($0) addi $10, $0, 0xffffff sw $10, 268504488($0) addi $10, $0, 0xffffff sw $10, 268504492($0) addi $10, $0, 0xffffff sw $10, 268504496($0) addi $10, $0, 0xffffff sw $10, 268504500($0) addi $10, $0, 0xffffff sw $10, 268504504($0) addi $10, $0, 0xffffff sw $10, 268504508($0) addi $10, $0, 0xffffff sw $10, 268504512($0) addi $10, $0, 0xffffff sw $10, 268504516($0) addi $10, $0, 0xffffff sw $10, 268504520($0) addi $10, $0, 0xffffff sw $10, 268504524($0) addi $10, $0, 0xffffff sw $10, 268504528($0) addi $10, $0, 0xffffff sw $10, 268504532($0) addi $10, $0, 0xffffff sw $10, 268504536($0) addi $10, $0, 0xffffff sw $10, 268504540($0) addi $10, $0, 0xffffff sw $10, 268504544($0) addi $10, $0, 0xffffff sw $10, 268504548($0) addi $10, $0, 0xffffff sw $10, 268504552($0) addi $10, $0, 0xffffff sw $10, 268504556($0) addi $10, $0, 0xffffff sw $10, 268504560($0) addi $10, $0, 0xffffff sw $10, 268504564($0) addi $10, $0, 0xffffff sw $10, 268504568($0) addi $10, $0, 0x00d800 sw $10, 268504572($0) addi $10, $0, 0x00d800 sw $10, 268504576($0) addi $10, $0, 0xffffff sw $10, 268504580($0) addi $10, $0, 0xffffff sw $10, 268504584($0) addi $10, $0, 0xffffff sw $10, 268504588($0) addi $10, $0, 0xffffff sw $10, 268504592($0) addi $10, $0, 0xffffff sw $10, 268504596($0) addi $10, $0, 0xffffff sw $10, 268504600($0) addi $10, $0, 0xffffff sw $10, 268504604($0) addi $10, $0, 0xffffff sw $10, 268504608($0) addi $10, $0, 0xffffff sw $10, 268504612($0) addi $10, $0, 0xffffff sw $10, 268504616($0) addi $10, $0, 0xffffff sw $10, 268504620($0) addi $10, $0, 0xffffff sw $10, 268504624($0) addi $10, $0, 0xffffff sw $10, 268504628($0) addi $10, $0, 0xffffff sw $10, 268504632($0) addi $10, $0, 0xffffff sw $10, 268504636($0) addi $10, $0, 0xffffff sw $10, 268504640($0) addi $10, $0, 0xffffff sw $10, 268504644($0) addi $10, $0, 0xffffff sw $10, 268504648($0) addi $10, $0, 0xffffff sw $10, 268504652($0) addi $10, $0, 0xffffff sw $10, 268504656($0) addi $10, $0, 0xffffff sw $10, 268504660($0) addi $10, $0, 0xffffff sw $10, 268504664($0) addi $10, $0, 0xffffff sw $10, 268504668($0) addi $10, $0, 0xffffff sw $10, 268504672($0) addi $10, $0, 0xffffff sw $10, 268504676($0) addi $10, $0, 0xffffff sw $10, 268504680($0) addi $10, $0, 0xffffff sw $10, 268504684($0) addi $10, $0, 0xffffff sw $10, 268504688($0) addi $10, $0, 0xffffff sw $10, 268504692($0) addi $10, $0, 0xffffff sw $10, 268504696($0) addi $10, $0, 0xffffff sw $10, 268504700($0) addi $10, $0, 0xffffff sw $10, 268504704($0) addi $10, $0, 0xffffff sw $10, 268504708($0) addi $10, $0, 0xffffff sw $10, 268504712($0) addi $10, $0, 0xffffff sw $10, 268504716($0) addi $10, $0, 0xffffff sw $10, 268504720($0) addi $10, $0, 0xffffff sw $10, 268504724($0) addi $10, $0, 0xffffff sw $10, 268504728($0) addi $10, $0, 0xffffff sw $10, 268504732($0) addi $10, $0, 0xffffff sw $10, 268504736($0) addi $10, $0, 0xffffff sw $10, 268504740($0) addi $10, $0, 0xffffff sw $10, 268504744($0) addi $10, $0, 0xffffff sw $10, 268504748($0) addi $10, $0, 0xffffff sw $10, 268504752($0) addi $10, $0, 0xffffff sw $10, 268504756($0) addi $10, $0, 0xffffff sw $10, 268504760($0) addi $10, $0, 0xffffff sw $10, 268504764($0) addi $10, $0, 0xffffff sw $10, 268504768($0) addi $10, $0, 0xffffff sw $10, 268504772($0) addi $10, $0, 0xffffff sw $10, 268504776($0) addi $10, $0, 0xffffff sw $10, 268504780($0) addi $10, $0, 0xffffff sw $10, 268504784($0) addi $10, $0, 0xffffff sw $10, 268504788($0) addi $10, $0, 0xffffff sw $10, 268504792($0) addi $10, $0, 0xffffff sw $10, 268504796($0) addi $10, $0, 0xffffff sw $10, 268504800($0) addi $10, $0, 0xffffff sw $10, 268504804($0) addi $10, $0, 0xffffff sw $10, 268504808($0) addi $10, $0, 0xffffff sw $10, 268504812($0) addi $10, $0, 0xffffff sw $10, 268504816($0) addi $10, $0, 0xffffff sw $10, 268504820($0) addi $10, $0, 0xffffff sw $10, 268504824($0) addi $10, $0, 0x00d800 sw $10, 268504828($0) addi $10, $0, 0x00d800 sw $10, 268504832($0) addi $10, $0, 0xffffff sw $10, 268504836($0) addi $10, $0, 0xffffff sw $10, 268504840($0) addi $10, $0, 0xffffff sw $10, 268504844($0) addi $10, $0, 0xffffff sw $10, 268504848($0) addi $10, $0, 0xffffff sw $10, 268504852($0) addi $10, $0, 0xffffff sw $10, 268504856($0) addi $10, $0, 0xffffff sw $10, 268504860($0) addi $10, $0, 0xffffff sw $10, 268504864($0) addi $10, $0, 0xffffff sw $10, 268504868($0) addi $10, $0, 0xffffff sw $10, 268504872($0) addi $10, $0, 0xffffff sw $10, 268504876($0) addi $10, $0, 0xffffff sw $10, 268504880($0) addi $10, $0, 0xffffff sw $10, 268504884($0) addi $10, $0, 0xffffff sw $10, 268504888($0) addi $10, $0, 0xffffff sw $10, 268504892($0) addi $10, $0, 0xffffff sw $10, 268504896($0) addi $10, $0, 0xffffff sw $10, 268504900($0) addi $10, $0, 0xffffff sw $10, 268504904($0) addi $10, $0, 0xffffff sw $10, 268504908($0) addi $10, $0, 0xffffff sw $10, 268504912($0) addi $10, $0, 0xffffff sw $10, 268504916($0) addi $10, $0, 0xffffff sw $10, 268504920($0) addi $10, $0, 0xffffff sw $10, 268504924($0) addi $10, $0, 0xffffff sw $10, 268504928($0) addi $10, $0, 0xffffff sw $10, 268504932($0) addi $10, $0, 0xffffff sw $10, 268504936($0) addi $10, $0, 0xffffff sw $10, 268504940($0) addi $10, $0, 0xffffff sw $10, 268504944($0) addi $10, $0, 0xffffff sw $10, 268504948($0) addi $10, $0, 0xffffff sw $10, 268504952($0) addi $10, $0, 0xffffff sw $10, 268504956($0) addi $10, $0, 0xffffff sw $10, 268504960($0) addi $10, $0, 0xffffff sw $10, 268504964($0) addi $10, $0, 0xffffff sw $10, 268504968($0) addi $10, $0, 0xffffff sw $10, 268504972($0) addi $10, $0, 0xffffff sw $10, 268504976($0) addi $10, $0, 0xffffff sw $10, 268504980($0) addi $10, $0, 0xffffff sw $10, 268504984($0) addi $10, $0, 0xffffff sw $10, 268504988($0) addi $10, $0, 0xffffff sw $10, 268504992($0) addi $10, $0, 0xffffff sw $10, 268504996($0) addi $10, $0, 0xffffff sw $10, 268505000($0) addi $10, $0, 0xffffff sw $10, 268505004($0) addi $10, $0, 0xffffff sw $10, 268505008($0) addi $10, $0, 0xffffff sw $10, 268505012($0) addi $10, $0, 0xffffff sw $10, 268505016($0) addi $10, $0, 0xffffff sw $10, 268505020($0) addi $10, $0, 0xffffff sw $10, 268505024($0) addi $10, $0, 0xffffff sw $10, 268505028($0) addi $10, $0, 0xffffff sw $10, 268505032($0) addi $10, $0, 0xffffff sw $10, 268505036($0) addi $10, $0, 0xffffff sw $10, 268505040($0) addi $10, $0, 0xffffff sw $10, 268505044($0) addi $10, $0, 0xffffff sw $10, 268505048($0) addi $10, $0, 0xffffff sw $10, 268505052($0) addi $10, $0, 0xffffff sw $10, 268505056($0) addi $10, $0, 0xffffff sw $10, 268505060($0) addi $10, $0, 0xffffff sw $10, 268505064($0) addi $10, $0, 0xffffff sw $10, 268505068($0) addi $10, $0, 0xffffff sw $10, 268505072($0) addi $10, $0, 0xffffff sw $10, 268505076($0) addi $10, $0, 0xffffff sw $10, 268505080($0) addi $10, $0, 0x00d800 sw $10, 268505084($0) addi $10, $0, 0x00d800 sw $10, 268505088($0) addi $10, $0, 0xffffff sw $10, 268505092($0) addi $10, $0, 0xffffff sw $10, 268505096($0) addi $10, $0, 0xffffff sw $10, 268505100($0) addi $10, $0, 0xffffff sw $10, 268505104($0) addi $10, $0, 0xffffff sw $10, 268505108($0) addi $10, $0, 0xffffff sw $10, 268505112($0) addi $10, $0, 0xffffff sw $10, 268505116($0) addi $10, $0, 0xffffff sw $10, 268505120($0) addi $10, $0, 0xffffff sw $10, 268505124($0) addi $10, $0, 0xffffff sw $10, 268505128($0) addi $10, $0, 0xffffff sw $10, 268505132($0) addi $10, $0, 0xffffff sw $10, 268505136($0) addi $10, $0, 0xffffff sw $10, 268505140($0) addi $10, $0, 0xffffff sw $10, 268505144($0) addi $10, $0, 0xffffff sw $10, 268505148($0) addi $10, $0, 0xffffff sw $10, 268505152($0) addi $10, $0, 0xffffff sw $10, 268505156($0) addi $10, $0, 0xffffff sw $10, 268505160($0) addi $10, $0, 0xffffff sw $10, 268505164($0) addi $10, $0, 0xffffff sw $10, 268505168($0) addi $10, $0, 0xffffff sw $10, 268505172($0) addi $10, $0, 0xffffff sw $10, 268505176($0) addi $10, $0, 0xffffff sw $10, 268505180($0) addi $10, $0, 0xffffff sw $10, 268505184($0) addi $10, $0, 0xffffff sw $10, 268505188($0) addi $10, $0, 0xffffff sw $10, 268505192($0) addi $10, $0, 0xffffff sw $10, 268505196($0) addi $10, $0, 0xffffff sw $10, 268505200($0) addi $10, $0, 0xffffff sw $10, 268505204($0) addi $10, $0, 0xffffff sw $10, 268505208($0) addi $10, $0, 0xffffff sw $10, 268505212($0) addi $10, $0, 0xffffff sw $10, 268505216($0) addi $10, $0, 0xffffff sw $10, 268505220($0) addi $10, $0, 0xffffff sw $10, 268505224($0) addi $10, $0, 0xffffff sw $10, 268505228($0) addi $10, $0, 0xffffff sw $10, 268505232($0) addi $10, $0, 0xffffff sw $10, 268505236($0) addi $10, $0, 0xffffff sw $10, 268505240($0) addi $10, $0, 0xffffff sw $10, 268505244($0) addi $10, $0, 0xffffff sw $10, 268505248($0) addi $10, $0, 0xffffff sw $10, 268505252($0) addi $10, $0, 0xffffff sw $10, 268505256($0) addi $10, $0, 0xffffff sw $10, 268505260($0) addi $10, $0, 0xffffff sw $10, 268505264($0) addi $10, $0, 0xffffff sw $10, 268505268($0) addi $10, $0, 0xffffff sw $10, 268505272($0) addi $10, $0, 0xffffff sw $10, 268505276($0) addi $10, $0, 0xffffff sw $10, 268505280($0) addi $10, $0, 0xffffff sw $10, 268505284($0) addi $10, $0, 0xffffff sw $10, 268505288($0) addi $10, $0, 0xffffff sw $10, 268505292($0) addi $10, $0, 0xffffff sw $10, 268505296($0) addi $10, $0, 0xffffff sw $10, 268505300($0) addi $10, $0, 0xffffff sw $10, 268505304($0) addi $10, $0, 0xffffff sw $10, 268505308($0) addi $10, $0, 0xffffff sw $10, 268505312($0) addi $10, $0, 0xffffff sw $10, 268505316($0) addi $10, $0, 0xffffff sw $10, 268505320($0) addi $10, $0, 0xffffff sw $10, 268505324($0) addi $10, $0, 0xffffff sw $10, 268505328($0) addi $10, $0, 0xffffff sw $10, 268505332($0) addi $10, $0, 0xffffff sw $10, 268505336($0) addi $10, $0, 0x00d800 sw $10, 268505340($0) addi $10, $0, 0x00d800 sw $10, 268505344($0) addi $10, $0, 0xffffff sw $10, 268505348($0) addi $10, $0, 0xffffff sw $10, 268505352($0) addi $10, $0, 0xffffff sw $10, 268505356($0) addi $10, $0, 0xffffff sw $10, 268505360($0) addi $10, $0, 0xffffff sw $10, 268505364($0) addi $10, $0, 0xffffff sw $10, 268505368($0) addi $10, $0, 0xffffff sw $10, 268505372($0) addi $10, $0, 0xffffff sw $10, 268505376($0) addi $10, $0, 0xffffff sw $10, 268505380($0) addi $10, $0, 0xffffff sw $10, 268505384($0) addi $10, $0, 0xffffff sw $10, 268505388($0) addi $10, $0, 0xffffff sw $10, 268505392($0) addi $10, $0, 0xffffff sw $10, 268505396($0) addi $10, $0, 0xffffff sw $10, 268505400($0) addi $10, $0, 0xffffff sw $10, 268505404($0) addi $10, $0, 0xffffff sw $10, 268505408($0) addi $10, $0, 0xffffff sw $10, 268505412($0) addi $10, $0, 0xffffff sw $10, 268505416($0) addi $10, $0, 0xffffff sw $10, 268505420($0) addi $10, $0, 0xffffff sw $10, 268505424($0) addi $10, $0, 0xffffff sw $10, 268505428($0) addi $10, $0, 0xffffff sw $10, 268505432($0) addi $10, $0, 0xffffff sw $10, 268505436($0) addi $10, $0, 0xf0851a sw $10, 268505440($0) addi $10, $0, 0xde8314 sw $10, 268505444($0) addi $10, $0, 0xd67c16 sw $10, 268505448($0) addi $10, $0, 0xf57a0a sw $10, 268505452($0) addi $10, $0, 0xce7110 sw $10, 268505456($0) addi $10, $0, 0xe0830d sw $10, 268505460($0) addi $10, $0, 0xe08116 sw $10, 268505464($0) addi $10, $0, 0xc96c07 sw $10, 268505468($0) addi $10, $0, 0xdb8110 sw $10, 268505472($0) addi $10, $0, 0xdc811a sw $10, 268505476($0) addi $10, $0, 0xd78219 sw $10, 268505480($0) addi $10, $0, 0xeb8000 sw $10, 268505484($0) addi $10, $0, 0xc56502 sw $10, 268505488($0) addi $10, $0, 0xd5871f sw $10, 268505492($0) addi $10, $0, 0xec820a sw $10, 268505496($0) addi $10, $0, 0xd07510 sw $10, 268505500($0) addi $10, $0, 0xd48e00 sw $10, 268505504($0) addi $10, $0, 0xffffff sw $10, 268505508($0) addi $10, $0, 0xffffff sw $10, 268505512($0) addi $10, $0, 0xffffff sw $10, 268505516($0) addi $10, $0, 0xffffff sw $10, 268505520($0) addi $10, $0, 0xffffff sw $10, 268505524($0) addi $10, $0, 0xffffff sw $10, 268505528($0) addi $10, $0, 0xffffff sw $10, 268505532($0) addi $10, $0, 0xffffff sw $10, 268505536($0) addi $10, $0, 0xffffff sw $10, 268505540($0) addi $10, $0, 0xffffff sw $10, 268505544($0) addi $10, $0, 0xffffff sw $10, 268505548($0) addi $10, $0, 0xffffff sw $10, 268505552($0) addi $10, $0, 0xffffff sw $10, 268505556($0) addi $10, $0, 0xffffff sw $10, 268505560($0) addi $10, $0, 0xffffff sw $10, 268505564($0) addi $10, $0, 0xffffff sw $10, 268505568($0) addi $10, $0, 0xffffff sw $10, 268505572($0) addi $10, $0, 0xffffff sw $10, 268505576($0) addi $10, $0, 0xffffff sw $10, 268505580($0) addi $10, $0, 0xffffff sw $10, 268505584($0) addi $10, $0, 0xffffff sw $10, 268505588($0) addi $10, $0, 0xffffff sw $10, 268505592($0) addi $10, $0, 0x00d800 sw $10, 268505596($0) addi $10, $0, 0x00d800 sw $10, 268505600($0) addi $10, $0, 0xffffff sw $10, 268505604($0) addi $10, $0, 0xffffff sw $10, 268505608($0) addi $10, $0, 0xffffff sw $10, 268505612($0) addi $10, $0, 0xffffff sw $10, 268505616($0) addi $10, $0, 0xffffff sw $10, 268505620($0) addi $10, $0, 0xffffff sw $10, 268505624($0) addi $10, $0, 0xffffff sw $10, 268505628($0) addi $10, $0, 0xffffff sw $10, 268505632($0) addi $10, $0, 0xffffff sw $10, 268505636($0) addi $10, $0, 0xffffff sw $10, 268505640($0) addi $10, $0, 0xffffff sw $10, 268505644($0) addi $10, $0, 0xffffff sw $10, 268505648($0) addi $10, $0, 0xffffff sw $10, 268505652($0) addi $10, $0, 0xffffff sw $10, 268505656($0) addi $10, $0, 0xffffff sw $10, 268505660($0) addi $10, $0, 0xffffff sw $10, 268505664($0) addi $10, $0, 0xffffff sw $10, 268505668($0) addi $10, $0, 0xffffff sw $10, 268505672($0) addi $10, $0, 0xffffff sw $10, 268505676($0) addi $10, $0, 0xffffff sw $10, 268505680($0) addi $10, $0, 0xffffff sw $10, 268505684($0) addi $10, $0, 0xffffff sw $10, 268505688($0) addi $10, $0, 0xffffff sw $10, 268505692($0) addi $10, $0, 0xf3790e sw $10, 268505696($0) addi $10, $0, 0xf89226 sw $10, 268505700($0) addi $10, $0, 0xe47a15 sw $10, 268505704($0) addi $10, $0, 0xfd760a sw $10, 268505708($0) addi $10, $0, 0xcf6a0e sw $10, 268505712($0) addi $10, $0, 0xf77907 sw $10, 268505716($0) addi $10, $0, 0xfb7711 sw $10, 268505720($0) addi $10, $0, 0xe66403 sw $10, 268505724($0) addi $10, $0, 0xf57708 sw $10, 268505728($0) addi $10, $0, 0xf67811 sw $10, 268505732($0) addi $10, $0, 0xf77b0e sw $10, 268505736($0) addi $10, $0, 0xff7a02 sw $10, 268505740($0) addi $10, $0, 0xd85900 sw $10, 268505744($0) addi $10, $0, 0xf08010 sw $10, 268505748($0) addi $10, $0, 0xf4810d sw $10, 268505752($0) addi $10, $0, 0xd77219 sw $10, 268505756($0) addi $10, $0, 0xfc771c sw $10, 268505760($0) addi $10, $0, 0xffffff sw $10, 268505764($0) addi $10, $0, 0xffffff sw $10, 268505768($0) addi $10, $0, 0xffffff sw $10, 268505772($0) addi $10, $0, 0xffffff sw $10, 268505776($0) addi $10, $0, 0xffffff sw $10, 268505780($0) addi $10, $0, 0xffffff sw $10, 268505784($0) addi $10, $0, 0xffffff sw $10, 268505788($0) addi $10, $0, 0xffffff sw $10, 268505792($0) addi $10, $0, 0xffffff sw $10, 268505796($0) addi $10, $0, 0xffffff sw $10, 268505800($0) addi $10, $0, 0xffffff sw $10, 268505804($0) addi $10, $0, 0xffffff sw $10, 268505808($0) addi $10, $0, 0xffffff sw $10, 268505812($0) addi $10, $0, 0xffffff sw $10, 268505816($0) addi $10, $0, 0xffffff sw $10, 268505820($0) addi $10, $0, 0xffffff sw $10, 268505824($0) addi $10, $0, 0xffffff sw $10, 268505828($0) addi $10, $0, 0xffffff sw $10, 268505832($0) addi $10, $0, 0xffffff sw $10, 268505836($0) addi $10, $0, 0xffffff sw $10, 268505840($0) addi $10, $0, 0xffffff sw $10, 268505844($0) addi $10, $0, 0xffffff sw $10, 268505848($0) addi $10, $0, 0x00d800 sw $10, 268505852($0) addi $10, $0, 0x00d800 sw $10, 268505856($0) addi $10, $0, 0xffffff sw $10, 268505860($0) addi $10, $0, 0xffffff sw $10, 268505864($0) addi $10, $0, 0xffffff sw $10, 268505868($0) addi $10, $0, 0xffffff sw $10, 268505872($0) addi $10, $0, 0xffffff sw $10, 268505876($0) addi $10, $0, 0xffffff sw $10, 268505880($0) addi $10, $0, 0xffffff sw $10, 268505884($0) addi $10, $0, 0xffffff sw $10, 268505888($0) addi $10, $0, 0xffffff sw $10, 268505892($0) addi $10, $0, 0xffffff sw $10, 268505896($0) addi $10, $0, 0xffffff sw $10, 268505900($0) addi $10, $0, 0xffffff sw $10, 268505904($0) addi $10, $0, 0xffffff sw $10, 268505908($0) addi $10, $0, 0xffffff sw $10, 268505912($0) addi $10, $0, 0xffffff sw $10, 268505916($0) addi $10, $0, 0xffffff sw $10, 268505920($0) addi $10, $0, 0xffffff sw $10, 268505924($0) addi $10, $0, 0xffffff sw $10, 268505928($0) addi $10, $0, 0xffffff sw $10, 268505932($0) addi $10, $0, 0xffffff sw $10, 268505936($0) addi $10, $0, 0xffffff sw $10, 268505940($0) addi $10, $0, 0xffffff sw $10, 268505944($0) addi $10, $0, 0xffffff sw $10, 268505948($0) addi $10, $0, 0xd77107 sw $10, 268505952($0) addi $10, $0, 0xd0780d sw $10, 268505956($0) addi $10, $0, 0xd58022 sw $10, 268505960($0) addi $10, $0, 0xd86c07 sw $10, 268505964($0) addi $10, $0, 0xb97423 sw $10, 268505968($0) addi $10, $0, 0xc27428 sw $10, 268505972($0) addi $10, $0, 0xc0712e sw $10, 268505976($0) addi $10, $0, 0xaf621d sw $10, 268505980($0) addi $10, $0, 0xbc7225 sw $10, 268505984($0) addi $10, $0, 0xbe732d sw $10, 268505988($0) addi $10, $0, 0xba6f30 sw $10, 268505992($0) addi $10, $0, 0xb76f39 sw $10, 268505996($0) addi $10, $0, 0xb45817 sw $10, 268506000($0) addi $10, $0, 0xe26e09 sw $10, 268506004($0) addi $10, $0, 0xe06f07 sw $10, 268506008($0) addi $10, $0, 0xce6814 sw $10, 268506012($0) addi $10, $0, 0xee701c sw $10, 268506016($0) addi $10, $0, 0xffffff sw $10, 268506020($0) addi $10, $0, 0xffffff sw $10, 268506024($0) addi $10, $0, 0xffffff sw $10, 268506028($0) addi $10, $0, 0xffffff sw $10, 268506032($0) addi $10, $0, 0xffffff sw $10, 268506036($0) addi $10, $0, 0xffffff sw $10, 268506040($0) addi $10, $0, 0xffffff sw $10, 268506044($0) addi $10, $0, 0xffffff sw $10, 268506048($0) addi $10, $0, 0xffffff sw $10, 268506052($0) addi $10, $0, 0xffffff sw $10, 268506056($0) addi $10, $0, 0xffffff sw $10, 268506060($0) addi $10, $0, 0xffffff sw $10, 268506064($0) addi $10, $0, 0xffffff sw $10, 268506068($0) addi $10, $0, 0xffffff sw $10, 268506072($0) addi $10, $0, 0xffffff sw $10, 268506076($0) addi $10, $0, 0xffffff sw $10, 268506080($0) addi $10, $0, 0xffffff sw $10, 268506084($0) addi $10, $0, 0xffffff sw $10, 268506088($0) addi $10, $0, 0xffffff sw $10, 268506092($0) addi $10, $0, 0xffffff sw $10, 268506096($0) addi $10, $0, 0xffffff sw $10, 268506100($0) addi $10, $0, 0xffffff sw $10, 268506104($0) addi $10, $0, 0x00d800 sw $10, 268506108($0) addi $10, $0, 0x00d800 sw $10, 268506112($0) addi $10, $0, 0xffffff sw $10, 268506116($0) addi $10, $0, 0xffffff sw $10, 268506120($0) addi $10, $0, 0xffffff sw $10, 268506124($0) addi $10, $0, 0xffffff sw $10, 268506128($0) addi $10, $0, 0xffffff sw $10, 268506132($0) addi $10, $0, 0xffffff sw $10, 268506136($0) addi $10, $0, 0xffffff sw $10, 268506140($0) addi $10, $0, 0xffffff sw $10, 268506144($0) addi $10, $0, 0xffffff sw $10, 268506148($0) addi $10, $0, 0xffffff sw $10, 268506152($0) addi $10, $0, 0xffffff sw $10, 268506156($0) addi $10, $0, 0xffffff sw $10, 268506160($0) addi $10, $0, 0xffffff sw $10, 268506164($0) addi $10, $0, 0xffffff sw $10, 268506168($0) addi $10, $0, 0xffffff sw $10, 268506172($0) addi $10, $0, 0xffffff sw $10, 268506176($0) addi $10, $0, 0xffffff sw $10, 268506180($0) addi $10, $0, 0xffffff sw $10, 268506184($0) addi $10, $0, 0xffffff sw $10, 268506188($0) addi $10, $0, 0xffffff sw $10, 268506192($0) addi $10, $0, 0xffffff sw $10, 268506196($0) addi $10, $0, 0xffffff sw $10, 268506200($0) addi $10, $0, 0xffffff sw $10, 268506204($0) addi $10, $0, 0xfb7717 sw $10, 268506208($0) addi $10, $0, 0xf47f1b sw $10, 268506212($0) addi $10, $0, 0xea7a21 sw $10, 268506216($0) addi $10, $0, 0xf8842b sw $10, 268506220($0) addi $10, $0, 0xcf7738 sw $10, 268506224($0) addi $10, $0, 0xfefaf6 sw $10, 268506228($0) addi $10, $0, 0xfdfaff sw $10, 268506232($0) addi $10, $0, 0xd9d6de sw $10, 268506236($0) addi $10, $0, 0xf9faf6 sw $10, 268506240($0) addi $10, $0, 0xfafbfd sw $10, 268506244($0) addi $10, $0, 0xfdf9f7 sw $10, 268506248($0) addi $10, $0, 0xfbfbfb sw $10, 268506252($0) addi $10, $0, 0xd3a281 sw $10, 268506256($0) addi $10, $0, 0xf3801b sw $10, 268506260($0) addi $10, $0, 0xf07f18 sw $10, 268506264($0) addi $10, $0, 0xdd7016 sw $10, 268506268($0) addi $10, $0, 0xf67e0e sw $10, 268506272($0) addi $10, $0, 0xffffff sw $10, 268506276($0) addi $10, $0, 0xffffff sw $10, 268506280($0) addi $10, $0, 0xffffff sw $10, 268506284($0) addi $10, $0, 0xffffff sw $10, 268506288($0) addi $10, $0, 0xffffff sw $10, 268506292($0) addi $10, $0, 0xffffff sw $10, 268506296($0) addi $10, $0, 0xffffff sw $10, 268506300($0) addi $10, $0, 0xffffff sw $10, 268506304($0) addi $10, $0, 0xffffff sw $10, 268506308($0) addi $10, $0, 0xffffff sw $10, 268506312($0) addi $10, $0, 0xffffff sw $10, 268506316($0) addi $10, $0, 0xffffff sw $10, 268506320($0) addi $10, $0, 0xffffff sw $10, 268506324($0) addi $10, $0, 0xffffff sw $10, 268506328($0) addi $10, $0, 0xffffff sw $10, 268506332($0) addi $10, $0, 0xffffff sw $10, 268506336($0) addi $10, $0, 0xffffff sw $10, 268506340($0) addi $10, $0, 0xffffff sw $10, 268506344($0) addi $10, $0, 0xffffff sw $10, 268506348($0) addi $10, $0, 0xffffff sw $10, 268506352($0) addi $10, $0, 0xffffff sw $10, 268506356($0) addi $10, $0, 0xffffff sw $10, 268506360($0) addi $10, $0, 0x00d800 sw $10, 268506364($0) addi $10, $0, 0x00d800 sw $10, 268506368($0) addi $10, $0, 0xffffff sw $10, 268506372($0) addi $10, $0, 0xffffff sw $10, 268506376($0) addi $10, $0, 0xffffff sw $10, 268506380($0) addi $10, $0, 0xffffff sw $10, 268506384($0) addi $10, $0, 0xffffff sw $10, 268506388($0) addi $10, $0, 0xffffff sw $10, 268506392($0) addi $10, $0, 0xffffff sw $10, 268506396($0) addi $10, $0, 0xffffff sw $10, 268506400($0) addi $10, $0, 0xffffff sw $10, 268506404($0) addi $10, $0, 0xffffff sw $10, 268506408($0) addi $10, $0, 0xffffff sw $10, 268506412($0) addi $10, $0, 0xffffff sw $10, 268506416($0) addi $10, $0, 0xffffff sw $10, 268506420($0) addi $10, $0, 0xffffff sw $10, 268506424($0) addi $10, $0, 0xffffff sw $10, 268506428($0) addi $10, $0, 0xffffff sw $10, 268506432($0) addi $10, $0, 0xffffff sw $10, 268506436($0) addi $10, $0, 0xffffff sw $10, 268506440($0) addi $10, $0, 0xffffff sw $10, 268506444($0) addi $10, $0, 0xffffff sw $10, 268506448($0) addi $10, $0, 0xffffff sw $10, 268506452($0) addi $10, $0, 0xffffff sw $10, 268506456($0) addi $10, $0, 0xffffff sw $10, 268506460($0) addi $10, $0, 0xfb7a09 sw $10, 268506464($0) addi $10, $0, 0xf5810d sw $10, 268506468($0) addi $10, $0, 0xeb7d16 sw $10, 268506472($0) addi $10, $0, 0xfc7c16 sw $10, 268506476($0) addi $10, $0, 0xd48338 sw $10, 268506480($0) addi $10, $0, 0xf8f6ee sw $10, 268506484($0) addi $10, $0, 0xfcf9ff sw $10, 268506488($0) addi $10, $0, 0xd4d3d7 sw $10, 268506492($0) addi $10, $0, 0xfcfdf5 sw $10, 268506496($0) addi $10, $0, 0xfafcf8 sw $10, 268506500($0) addi $10, $0, 0xf9f5ec sw $10, 268506504($0) addi $10, $0, 0xf1fafd sw $10, 268506508($0) addi $10, $0, 0xcc9975 sw $10, 268506512($0) addi $10, $0, 0xff7b09 sw $10, 268506516($0) addi $10, $0, 0xfb7d10 sw $10, 268506520($0) addi $10, $0, 0xe86c0f sw $10, 268506524($0) addi $10, $0, 0xfd750d sw $10, 268506528($0) addi $10, $0, 0xffffff sw $10, 268506532($0) addi $10, $0, 0xffffff sw $10, 268506536($0) addi $10, $0, 0xffffff sw $10, 268506540($0) addi $10, $0, 0xffffff sw $10, 268506544($0) addi $10, $0, 0xffffff sw $10, 268506548($0) addi $10, $0, 0xffffff sw $10, 268506552($0) addi $10, $0, 0xffffff sw $10, 268506556($0) addi $10, $0, 0xffffff sw $10, 268506560($0) addi $10, $0, 0xffffff sw $10, 268506564($0) addi $10, $0, 0xffffff sw $10, 268506568($0) addi $10, $0, 0xffffff sw $10, 268506572($0) addi $10, $0, 0xffffff sw $10, 268506576($0) addi $10, $0, 0xffffff sw $10, 268506580($0) addi $10, $0, 0xffffff sw $10, 268506584($0) addi $10, $0, 0xffffff sw $10, 268506588($0) addi $10, $0, 0xffffff sw $10, 268506592($0) addi $10, $0, 0xffffff sw $10, 268506596($0) addi $10, $0, 0xffffff sw $10, 268506600($0) addi $10, $0, 0xffffff sw $10, 268506604($0) addi $10, $0, 0xffffff sw $10, 268506608($0) addi $10, $0, 0xffffff sw $10, 268506612($0) addi $10, $0, 0xffffff sw $10, 268506616($0) addi $10, $0, 0x00d800 sw $10, 268506620($0) addi $10, $0, 0x00d800 sw $10, 268506624($0) addi $10, $0, 0xffffff sw $10, 268506628($0) addi $10, $0, 0xffffff sw $10, 268506632($0) addi $10, $0, 0xffffff sw $10, 268506636($0) addi $10, $0, 0xffffff sw $10, 268506640($0) addi $10, $0, 0xffffff sw $10, 268506644($0) addi $10, $0, 0xffffff sw $10, 268506648($0) addi $10, $0, 0xffffff sw $10, 268506652($0) addi $10, $0, 0xffffff sw $10, 268506656($0) addi $10, $0, 0xffffff sw $10, 268506660($0) addi $10, $0, 0xffffff sw $10, 268506664($0) addi $10, $0, 0xffffff sw $10, 268506668($0) addi $10, $0, 0xffffff sw $10, 268506672($0) addi $10, $0, 0xffffff sw $10, 268506676($0) addi $10, $0, 0xffffff sw $10, 268506680($0) addi $10, $0, 0xffffff sw $10, 268506684($0) addi $10, $0, 0xffffff sw $10, 268506688($0) addi $10, $0, 0xffffff sw $10, 268506692($0) addi $10, $0, 0xffffff sw $10, 268506696($0) addi $10, $0, 0xffffff sw $10, 268506700($0) addi $10, $0, 0xffffff sw $10, 268506704($0) addi $10, $0, 0xffffff sw $10, 268506708($0) addi $10, $0, 0xffffff sw $10, 268506712($0) addi $10, $0, 0xffffff sw $10, 268506716($0) addi $10, $0, 0xd16302 sw $10, 268506720($0) addi $10, $0, 0xbb6823 sw $10, 268506724($0) addi $10, $0, 0xd4a88c sw $10, 268506728($0) addi $10, $0, 0xd7bdae sw $10, 268506732($0) addi $10, $0, 0xc9a287 sw $10, 268506736($0) addi $10, $0, 0xb97435 sw $10, 268506740($0) addi $10, $0, 0xa16327 sw $10, 268506744($0) addi $10, $0, 0x924e1f sw $10, 268506748($0) addi $10, $0, 0xaf6124 sw $10, 268506752($0) addi $10, $0, 0xaa6224 sw $10, 268506756($0) addi $10, $0, 0xa25e37 sw $10, 268506760($0) addi $10, $0, 0xb5602a sw $10, 268506764($0) addi $10, $0, 0xa96937 sw $10, 268506768($0) addi $10, $0, 0xdac2a7 sw $10, 268506772($0) addi $10, $0, 0xdcbea5 sw $10, 268506776($0) addi $10, $0, 0xc45c10 sw $10, 268506780($0) addi $10, $0, 0xd95d0d sw $10, 268506784($0) addi $10, $0, 0xffffff sw $10, 268506788($0) addi $10, $0, 0xffffff sw $10, 268506792($0) addi $10, $0, 0xffffff sw $10, 268506796($0) addi $10, $0, 0xffffff sw $10, 268506800($0) addi $10, $0, 0xffffff sw $10, 268506804($0) addi $10, $0, 0xffffff sw $10, 268506808($0) addi $10, $0, 0xffffff sw $10, 268506812($0) addi $10, $0, 0xffffff sw $10, 268506816($0) addi $10, $0, 0xffffff sw $10, 268506820($0) addi $10, $0, 0xffffff sw $10, 268506824($0) addi $10, $0, 0xffffff sw $10, 268506828($0) addi $10, $0, 0xffffff sw $10, 268506832($0) addi $10, $0, 0xffffff sw $10, 268506836($0) addi $10, $0, 0xffffff sw $10, 268506840($0) addi $10, $0, 0xffffff sw $10, 268506844($0) addi $10, $0, 0xffffff sw $10, 268506848($0) addi $10, $0, 0xffffff sw $10, 268506852($0) addi $10, $0, 0xffffff sw $10, 268506856($0) addi $10, $0, 0xffffff sw $10, 268506860($0) addi $10, $0, 0xffffff sw $10, 268506864($0) addi $10, $0, 0xffffff sw $10, 268506868($0) addi $10, $0, 0xffffff sw $10, 268506872($0) addi $10, $0, 0x00d800 sw $10, 268506876($0) addi $10, $0, 0x00d800 sw $10, 268506880($0) addi $10, $0, 0xffffff sw $10, 268506884($0) addi $10, $0, 0xffffff sw $10, 268506888($0) addi $10, $0, 0xffffff sw $10, 268506892($0) addi $10, $0, 0xffffff sw $10, 268506896($0) addi $10, $0, 0xffffff sw $10, 268506900($0) addi $10, $0, 0xffffff sw $10, 268506904($0) addi $10, $0, 0xffffff sw $10, 268506908($0) addi $10, $0, 0xffffff sw $10, 268506912($0) addi $10, $0, 0xffffff sw $10, 268506916($0) addi $10, $0, 0xffffff sw $10, 268506920($0) addi $10, $0, 0xffffff sw $10, 268506924($0) addi $10, $0, 0xffffff sw $10, 268506928($0) addi $10, $0, 0xffffff sw $10, 268506932($0) addi $10, $0, 0xffffff sw $10, 268506936($0) addi $10, $0, 0xffffff sw $10, 268506940($0) addi $10, $0, 0xffffff sw $10, 268506944($0) addi $10, $0, 0xffffff sw $10, 268506948($0) addi $10, $0, 0xffffff sw $10, 268506952($0) addi $10, $0, 0xffffff sw $10, 268506956($0) addi $10, $0, 0xffffff sw $10, 268506960($0) addi $10, $0, 0xffffff sw $10, 268506964($0) addi $10, $0, 0xffffff sw $10, 268506968($0) addi $10, $0, 0xffffff sw $10, 268506972($0) addi $10, $0, 0xf07e02 sw $10, 268506976($0) addi $10, $0, 0xeb7f10 sw $10, 268506980($0) addi $10, $0, 0xeed8ac sw $10, 268506984($0) addi $10, $0, 0xf4fffd sw $10, 268506988($0) addi $10, $0, 0xe9d5b2 sw $10, 268506992($0) addi $10, $0, 0xf08012 sw $10, 268506996($0) addi $10, $0, 0xed8115 sw $10, 268507000($0) addi $10, $0, 0xd56405 sw $10, 268507004($0) addi $10, $0, 0xf67e11 sw $10, 268507008($0) addi $10, $0, 0xf17c0f sw $10, 268507012($0) addi $10, $0, 0xed8107 sw $10, 268507016($0) addi $10, $0, 0xf17f03 sw $10, 268507020($0) addi $10, $0, 0xca8851 sw $10, 268507024($0) addi $10, $0, 0xfdf8ff sw $10, 268507028($0) addi $10, $0, 0xfffbfc sw $10, 268507032($0) addi $10, $0, 0xc97424 sw $10, 268507036($0) addi $10, $0, 0xf57f04 sw $10, 268507040($0) addi $10, $0, 0xffffff sw $10, 268507044($0) addi $10, $0, 0xffffff sw $10, 268507048($0) addi $10, $0, 0xffffff sw $10, 268507052($0) addi $10, $0, 0xffffff sw $10, 268507056($0) addi $10, $0, 0xffffff sw $10, 268507060($0) addi $10, $0, 0xffffff sw $10, 268507064($0) addi $10, $0, 0xffffff sw $10, 268507068($0) addi $10, $0, 0xffffff sw $10, 268507072($0) addi $10, $0, 0xffffff sw $10, 268507076($0) addi $10, $0, 0xffffff sw $10, 268507080($0) addi $10, $0, 0xffffff sw $10, 268507084($0) addi $10, $0, 0xffffff sw $10, 268507088($0) addi $10, $0, 0xffffff sw $10, 268507092($0) addi $10, $0, 0xffffff sw $10, 268507096($0) addi $10, $0, 0xffffff sw $10, 268507100($0) addi $10, $0, 0xffffff sw $10, 268507104($0) addi $10, $0, 0xffffff sw $10, 268507108($0) addi $10, $0, 0xffffff sw $10, 268507112($0) addi $10, $0, 0xffffff sw $10, 268507116($0) addi $10, $0, 0xffffff sw $10, 268507120($0) addi $10, $0, 0xffffff sw $10, 268507124($0) addi $10, $0, 0xffffff sw $10, 268507128($0) addi $10, $0, 0x00d800 sw $10, 268507132($0) addi $10, $0, 0x00d800 sw $10, 268507136($0) addi $10, $0, 0xffffff sw $10, 268507140($0) addi $10, $0, 0xffffff sw $10, 268507144($0) addi $10, $0, 0xffffff sw $10, 268507148($0) addi $10, $0, 0xffffff sw $10, 268507152($0) addi $10, $0, 0xffffff sw $10, 268507156($0) addi $10, $0, 0xffffff sw $10, 268507160($0) addi $10, $0, 0xffffff sw $10, 268507164($0) addi $10, $0, 0xffffff sw $10, 268507168($0) addi $10, $0, 0xffffff sw $10, 268507172($0) addi $10, $0, 0xffffff sw $10, 268507176($0) addi $10, $0, 0xffffff sw $10, 268507180($0) addi $10, $0, 0xffffff sw $10, 268507184($0) addi $10, $0, 0xffffff sw $10, 268507188($0) addi $10, $0, 0xffffff sw $10, 268507192($0) addi $10, $0, 0xffffff sw $10, 268507196($0) addi $10, $0, 0xffffff sw $10, 268507200($0) addi $10, $0, 0xffffff sw $10, 268507204($0) addi $10, $0, 0xffffff sw $10, 268507208($0) addi $10, $0, 0xffffff sw $10, 268507212($0) addi $10, $0, 0xffffff sw $10, 268507216($0) addi $10, $0, 0xffffff sw $10, 268507220($0) addi $10, $0, 0xffffff sw $10, 268507224($0) addi $10, $0, 0xffffff sw $10, 268507228($0) addi $10, $0, 0xfd8121 sw $10, 268507232($0) addi $10, $0, 0xec7d2e sw $10, 268507236($0) addi $10, $0, 0xf3d4af sw $10, 268507240($0) addi $10, $0, 0xfff8e9 sw $10, 268507244($0) addi $10, $0, 0xfddbc1 sw $10, 268507248($0) addi $10, $0, 0xf78015 sw $10, 268507252($0) addi $10, $0, 0xe9780d sw $10, 268507256($0) addi $10, $0, 0xdd690e sw $10, 268507260($0) addi $10, $0, 0xf87c13 sw $10, 268507264($0) addi $10, $0, 0xf37f15 sw $10, 268507268($0) addi $10, $0, 0xf97e17 sw $10, 268507272($0) addi $10, $0, 0xfa7812 sw $10, 268507276($0) addi $10, $0, 0xc78861 sw $10, 268507280($0) addi $10, $0, 0xf6fcff sw $10, 268507284($0) addi $10, $0, 0xf9fbeb sw $10, 268507288($0) addi $10, $0, 0xd17913 sw $10, 268507292($0) addi $10, $0, 0xf77b0b sw $10, 268507296($0) addi $10, $0, 0xffffff sw $10, 268507300($0) addi $10, $0, 0xffffff sw $10, 268507304($0) addi $10, $0, 0xffffff sw $10, 268507308($0) addi $10, $0, 0xffffff sw $10, 268507312($0) addi $10, $0, 0xffffff sw $10, 268507316($0) addi $10, $0, 0xffffff sw $10, 268507320($0) addi $10, $0, 0xffffff sw $10, 268507324($0) addi $10, $0, 0xffffff sw $10, 268507328($0) addi $10, $0, 0xffffff sw $10, 268507332($0) addi $10, $0, 0xffffff sw $10, 268507336($0) addi $10, $0, 0xffffff sw $10, 268507340($0) addi $10, $0, 0xffffff sw $10, 268507344($0) addi $10, $0, 0xffffff sw $10, 268507348($0) addi $10, $0, 0xffffff sw $10, 268507352($0) addi $10, $0, 0xffffff sw $10, 268507356($0) addi $10, $0, 0xffffff sw $10, 268507360($0) addi $10, $0, 0xffffff sw $10, 268507364($0) addi $10, $0, 0xffffff sw $10, 268507368($0) addi $10, $0, 0xffffff sw $10, 268507372($0) addi $10, $0, 0xffffff sw $10, 268507376($0) addi $10, $0, 0xffffff sw $10, 268507380($0) addi $10, $0, 0xffffff sw $10, 268507384($0) addi $10, $0, 0x00d800 sw $10, 268507388($0) addi $10, $0, 0x00d800 sw $10, 268507392($0) addi $10, $0, 0xffffff sw $10, 268507396($0) addi $10, $0, 0xffffff sw $10, 268507400($0) addi $10, $0, 0xffffff sw $10, 268507404($0) addi $10, $0, 0xffffff sw $10, 268507408($0) addi $10, $0, 0xffffff sw $10, 268507412($0) addi $10, $0, 0xffffff sw $10, 268507416($0) addi $10, $0, 0xffffff sw $10, 268507420($0) addi $10, $0, 0xffffff sw $10, 268507424($0) addi $10, $0, 0xffffff sw $10, 268507428($0) addi $10, $0, 0xffffff sw $10, 268507432($0) addi $10, $0, 0xffffff sw $10, 268507436($0) addi $10, $0, 0xffffff sw $10, 268507440($0) addi $10, $0, 0xffffff sw $10, 268507444($0) addi $10, $0, 0xffffff sw $10, 268507448($0) addi $10, $0, 0xffffff sw $10, 268507452($0) addi $10, $0, 0xffffff sw $10, 268507456($0) addi $10, $0, 0xffffff sw $10, 268507460($0) addi $10, $0, 0xffffff sw $10, 268507464($0) addi $10, $0, 0xffffff sw $10, 268507468($0) addi $10, $0, 0xffffff sw $10, 268507472($0) addi $10, $0, 0xffffff sw $10, 268507476($0) addi $10, $0, 0xffffff sw $10, 268507480($0) addi $10, $0, 0xffffff sw $10, 268507484($0) addi $10, $0, 0xf67d0c sw $10, 268507488($0) addi $10, $0, 0xe5862e sw $10, 268507492($0) addi $10, $0, 0xdf741a sw $10, 268507496($0) addi $10, $0, 0xea7913 sw $10, 268507500($0) addi $10, $0, 0xc9741e sw $10, 268507504($0) addi $10, $0, 0xfe8016 sw $10, 268507508($0) addi $10, $0, 0xf57f19 sw $10, 268507512($0) addi $10, $0, 0xe26914 sw $10, 268507516($0) addi $10, $0, 0xf88b2c sw $10, 268507520($0) addi $10, $0, 0xf78122 sw $10, 268507524($0) addi $10, $0, 0xf47a23 sw $10, 268507528($0) addi $10, $0, 0xf77c1b sw $10, 268507532($0) addi $10, $0, 0xbd864c sw $10, 268507536($0) addi $10, $0, 0xf7fefa sw $10, 268507540($0) addi $10, $0, 0xfff5fb sw $10, 268507544($0) addi $10, $0, 0xd66730 sw $10, 268507548($0) addi $10, $0, 0xfc7f0e sw $10, 268507552($0) addi $10, $0, 0xffffff sw $10, 268507556($0) addi $10, $0, 0xffffff sw $10, 268507560($0) addi $10, $0, 0xffffff sw $10, 268507564($0) addi $10, $0, 0xffffff sw $10, 268507568($0) addi $10, $0, 0xffffff sw $10, 268507572($0) addi $10, $0, 0xffffff sw $10, 268507576($0) addi $10, $0, 0xffffff sw $10, 268507580($0) addi $10, $0, 0xffffff sw $10, 268507584($0) addi $10, $0, 0xffffff sw $10, 268507588($0) addi $10, $0, 0xffffff sw $10, 268507592($0) addi $10, $0, 0xffffff sw $10, 268507596($0) addi $10, $0, 0xffffff sw $10, 268507600($0) addi $10, $0, 0xffffff sw $10, 268507604($0) addi $10, $0, 0xffffff sw $10, 268507608($0) addi $10, $0, 0xffffff sw $10, 268507612($0) addi $10, $0, 0xffffff sw $10, 268507616($0) addi $10, $0, 0xffffff sw $10, 268507620($0) addi $10, $0, 0xffffff sw $10, 268507624($0) addi $10, $0, 0xffffff sw $10, 268507628($0) addi $10, $0, 0xffffff sw $10, 268507632($0) addi $10, $0, 0xffffff sw $10, 268507636($0) addi $10, $0, 0xffffff sw $10, 268507640($0) addi $10, $0, 0x00d800 sw $10, 268507644($0) addi $10, $0, 0x00d800 sw $10, 268507648($0) addi $10, $0, 0xffffff sw $10, 268507652($0) addi $10, $0, 0xffffff sw $10, 268507656($0) addi $10, $0, 0xffffff sw $10, 268507660($0) addi $10, $0, 0xffffff sw $10, 268507664($0) addi $10, $0, 0xffffff sw $10, 268507668($0) addi $10, $0, 0xffffff sw $10, 268507672($0) addi $10, $0, 0xffffff sw $10, 268507676($0) addi $10, $0, 0xffffff sw $10, 268507680($0) addi $10, $0, 0xffffff sw $10, 268507684($0) addi $10, $0, 0xffffff sw $10, 268507688($0) addi $10, $0, 0xffffff sw $10, 268507692($0) addi $10, $0, 0xffffff sw $10, 268507696($0) addi $10, $0, 0xffffff sw $10, 268507700($0) addi $10, $0, 0xffffff sw $10, 268507704($0) addi $10, $0, 0xffffff sw $10, 268507708($0) addi $10, $0, 0xffffff sw $10, 268507712($0) addi $10, $0, 0xffffff sw $10, 268507716($0) addi $10, $0, 0xffffff sw $10, 268507720($0) addi $10, $0, 0xffffff sw $10, 268507724($0) addi $10, $0, 0xffffff sw $10, 268507728($0) addi $10, $0, 0xffffff sw $10, 268507732($0) addi $10, $0, 0xffffff sw $10, 268507736($0) addi $10, $0, 0xffffff sw $10, 268507740($0) addi $10, $0, 0xfb800f sw $10, 268507744($0) addi $10, $0, 0xf77e12 sw $10, 268507748($0) addi $10, $0, 0xf2750f sw $10, 268507752($0) addi $10, $0, 0xfd8413 sw $10, 268507756($0) addi $10, $0, 0xe16e05 sw $10, 268507760($0) addi $10, $0, 0xf97b07 sw $10, 268507764($0) addi $10, $0, 0xf38012 sw $10, 268507768($0) addi $10, $0, 0xdd690e sw $10, 268507772($0) addi $10, $0, 0xfc821d sw $10, 268507776($0) addi $10, $0, 0xf28420 sw $10, 268507780($0) addi $10, $0, 0xf88218 sw $10, 268507784($0) addi $10, $0, 0xf87b07 sw $10, 268507788($0) addi $10, $0, 0xc6834b sw $10, 268507792($0) addi $10, $0, 0xfaf9fc sw $10, 268507796($0) addi $10, $0, 0xfff7f7 sw $10, 268507800($0) addi $10, $0, 0xcd6f26 sw $10, 268507804($0) addi $10, $0, 0xfe7f0d sw $10, 268507808($0) addi $10, $0, 0xffffff sw $10, 268507812($0) addi $10, $0, 0xffffff sw $10, 268507816($0) addi $10, $0, 0xffffff sw $10, 268507820($0) addi $10, $0, 0xffffff sw $10, 268507824($0) addi $10, $0, 0xffffff sw $10, 268507828($0) addi $10, $0, 0xffffff sw $10, 268507832($0) addi $10, $0, 0xffffff sw $10, 268507836($0) addi $10, $0, 0xffffff sw $10, 268507840($0) addi $10, $0, 0xffffff sw $10, 268507844($0) addi $10, $0, 0xffffff sw $10, 268507848($0) addi $10, $0, 0xffffff sw $10, 268507852($0) addi $10, $0, 0xffffff sw $10, 268507856($0) addi $10, $0, 0xffffff sw $10, 268507860($0) addi $10, $0, 0xffffff sw $10, 268507864($0) addi $10, $0, 0xffffff sw $10, 268507868($0) addi $10, $0, 0xffffff sw $10, 268507872($0) addi $10, $0, 0xffffff sw $10, 268507876($0) addi $10, $0, 0xffffff sw $10, 268507880($0) addi $10, $0, 0xffffff sw $10, 268507884($0) addi $10, $0, 0xffffff sw $10, 268507888($0) addi $10, $0, 0xffffff sw $10, 268507892($0) addi $10, $0, 0xffffff sw $10, 268507896($0) addi $10, $0, 0x00d800 sw $10, 268507900($0) addi $10, $0, 0x00d800 sw $10, 268507904($0) addi $10, $0, 0xffffff sw $10, 268507908($0) addi $10, $0, 0xffffff sw $10, 268507912($0) addi $10, $0, 0xffffff sw $10, 268507916($0) addi $10, $0, 0xffffff sw $10, 268507920($0) addi $10, $0, 0xffffff sw $10, 268507924($0) addi $10, $0, 0xffffff sw $10, 268507928($0) addi $10, $0, 0xffffff sw $10, 268507932($0) addi $10, $0, 0xffffff sw $10, 268507936($0) addi $10, $0, 0xffffff sw $10, 268507940($0) addi $10, $0, 0xffffff sw $10, 268507944($0) addi $10, $0, 0xffffff sw $10, 268507948($0) addi $10, $0, 0xffffff sw $10, 268507952($0) addi $10, $0, 0xffffff sw $10, 268507956($0) addi $10, $0, 0xffffff sw $10, 268507960($0) addi $10, $0, 0xffffff sw $10, 268507964($0) addi $10, $0, 0xffffff sw $10, 268507968($0) addi $10, $0, 0xffffff sw $10, 268507972($0) addi $10, $0, 0xffffff sw $10, 268507976($0) addi $10, $0, 0xffffff sw $10, 268507980($0) addi $10, $0, 0xffffff sw $10, 268507984($0) addi $10, $0, 0xffffff sw $10, 268507988($0) addi $10, $0, 0xffffff sw $10, 268507992($0) addi $10, $0, 0xffffff sw $10, 268507996($0) addi $10, $0, 0xb14400 sw $10, 268508000($0) addi $10, $0, 0xb14600 sw $10, 268508004($0) addi $10, $0, 0xa24600 sw $10, 268508008($0) addi $10, $0, 0xb14500 sw $10, 268508012($0) addi $10, $0, 0x993d00 sw $10, 268508016($0) addi $10, $0, 0xb74200 sw $10, 268508020($0) addi $10, $0, 0xb94500 sw $10, 268508024($0) addi $10, $0, 0x9b5d2e sw $10, 268508028($0) addi $10, $0, 0xa17a56 sw $10, 268508032($0) addi $10, $0, 0xa8794a sw $10, 268508036($0) addi $10, $0, 0x976b45 sw $10, 268508040($0) addi $10, $0, 0xa3766b sw $10, 268508044($0) addi $10, $0, 0x8f5a34 sw $10, 268508048($0) addi $10, $0, 0xae6230 sw $10, 268508052($0) addi $10, $0, 0xad6936 sw $10, 268508056($0) addi $10, $0, 0xab4600 sw $10, 268508060($0) addi $10, $0, 0xbe4000 sw $10, 268508064($0) addi $10, $0, 0xffffff sw $10, 268508068($0) addi $10, $0, 0xffffff sw $10, 268508072($0) addi $10, $0, 0xffffff sw $10, 268508076($0) addi $10, $0, 0xffffff sw $10, 268508080($0) addi $10, $0, 0xffffff sw $10, 268508084($0) addi $10, $0, 0xffffff sw $10, 268508088($0) addi $10, $0, 0xffffff sw $10, 268508092($0) addi $10, $0, 0xffffff sw $10, 268508096($0) addi $10, $0, 0xffffff sw $10, 268508100($0) addi $10, $0, 0xffffff sw $10, 268508104($0) addi $10, $0, 0xffffff sw $10, 268508108($0) addi $10, $0, 0xffffff sw $10, 268508112($0) addi $10, $0, 0xffffff sw $10, 268508116($0) addi $10, $0, 0xffffff sw $10, 268508120($0) addi $10, $0, 0xffffff sw $10, 268508124($0) addi $10, $0, 0xffffff sw $10, 268508128($0) addi $10, $0, 0xffffff sw $10, 268508132($0) addi $10, $0, 0xffffff sw $10, 268508136($0) addi $10, $0, 0xffffff sw $10, 268508140($0) addi $10, $0, 0xffffff sw $10, 268508144($0) addi $10, $0, 0xffffff sw $10, 268508148($0) addi $10, $0, 0xffffff sw $10, 268508152($0) addi $10, $0, 0x00d800 sw $10, 268508156($0) addi $10, $0, 0x00d800 sw $10, 268508160($0) addi $10, $0, 0xffffff sw $10, 268508164($0) addi $10, $0, 0xffffff sw $10, 268508168($0) addi $10, $0, 0xffffff sw $10, 268508172($0) addi $10, $0, 0xffffff sw $10, 268508176($0) addi $10, $0, 0xffffff sw $10, 268508180($0) addi $10, $0, 0xffffff sw $10, 268508184($0) addi $10, $0, 0xffffff sw $10, 268508188($0) addi $10, $0, 0xffffff sw $10, 268508192($0) addi $10, $0, 0xffffff sw $10, 268508196($0) addi $10, $0, 0xffffff sw $10, 268508200($0) addi $10, $0, 0xffffff sw $10, 268508204($0) addi $10, $0, 0xffffff sw $10, 268508208($0) addi $10, $0, 0xffffff sw $10, 268508212($0) addi $10, $0, 0xffffff sw $10, 268508216($0) addi $10, $0, 0xffffff sw $10, 268508220($0) addi $10, $0, 0xffffff sw $10, 268508224($0) addi $10, $0, 0xffffff sw $10, 268508228($0) addi $10, $0, 0xffffff sw $10, 268508232($0) addi $10, $0, 0xffffff sw $10, 268508236($0) addi $10, $0, 0xffffff sw $10, 268508240($0) addi $10, $0, 0xffffff sw $10, 268508244($0) addi $10, $0, 0xffffff sw $10, 268508248($0) addi $10, $0, 0xffffff sw $10, 268508252($0) addi $10, $0, 0xfa7406 sw $10, 268508256($0) addi $10, $0, 0xfc7d12 sw $10, 268508260($0) addi $10, $0, 0xe4740f sw $10, 268508264($0) addi $10, $0, 0xff7806 sw $10, 268508268($0) addi $10, $0, 0xda6809 sw $10, 268508272($0) addi $10, $0, 0xf28017 sw $10, 268508276($0) addi $10, $0, 0xf18520 sw $10, 268508280($0) addi $10, $0, 0xddba99 sw $10, 268508284($0) addi $10, $0, 0xfbfcff sw $10, 268508288($0) addi $10, $0, 0xfcfbff sw $10, 268508292($0) addi $10, $0, 0xf9f7ec sw $10, 268508296($0) addi $10, $0, 0xe9e4e3 sw $10, 268508300($0) addi $10, $0, 0xd0a768 sw $10, 268508304($0) addi $10, $0, 0xfc7c04 sw $10, 268508308($0) addi $10, $0, 0xec7d13 sw $10, 268508312($0) addi $10, $0, 0xd47a0d sw $10, 268508316($0) addi $10, $0, 0xf77f0a sw $10, 268508320($0) addi $10, $0, 0xffffff sw $10, 268508324($0) addi $10, $0, 0xffffff sw $10, 268508328($0) addi $10, $0, 0xffffff sw $10, 268508332($0) addi $10, $0, 0xffffff sw $10, 268508336($0) addi $10, $0, 0xffffff sw $10, 268508340($0) addi $10, $0, 0xffffff sw $10, 268508344($0) addi $10, $0, 0xffffff sw $10, 268508348($0) addi $10, $0, 0xffffff sw $10, 268508352($0) addi $10, $0, 0xffffff sw $10, 268508356($0) addi $10, $0, 0xffffff sw $10, 268508360($0) addi $10, $0, 0xffffff sw $10, 268508364($0) addi $10, $0, 0xffffff sw $10, 268508368($0) addi $10, $0, 0xffffff sw $10, 268508372($0) addi $10, $0, 0xffffff sw $10, 268508376($0) addi $10, $0, 0xffffff sw $10, 268508380($0) addi $10, $0, 0xffffff sw $10, 268508384($0) addi $10, $0, 0xffffff sw $10, 268508388($0) addi $10, $0, 0xffffff sw $10, 268508392($0) addi $10, $0, 0xffffff sw $10, 268508396($0) addi $10, $0, 0xffffff sw $10, 268508400($0) addi $10, $0, 0xffffff sw $10, 268508404($0) addi $10, $0, 0xffffff sw $10, 268508408($0) addi $10, $0, 0x00d800 sw $10, 268508412($0) addi $10, $0, 0x00d800 sw $10, 268508416($0) addi $10, $0, 0xffffff sw $10, 268508420($0) addi $10, $0, 0xffffff sw $10, 268508424($0) addi $10, $0, 0xffffff sw $10, 268508428($0) addi $10, $0, 0xffffff sw $10, 268508432($0) addi $10, $0, 0xffffff sw $10, 268508436($0) addi $10, $0, 0xffffff sw $10, 268508440($0) addi $10, $0, 0xffffff sw $10, 268508444($0) addi $10, $0, 0xffffff sw $10, 268508448($0) addi $10, $0, 0xffffff sw $10, 268508452($0) addi $10, $0, 0xffffff sw $10, 268508456($0) addi $10, $0, 0xffffff sw $10, 268508460($0) addi $10, $0, 0xffffff sw $10, 268508464($0) addi $10, $0, 0xffffff sw $10, 268508468($0) addi $10, $0, 0xffffff sw $10, 268508472($0) addi $10, $0, 0xffffff sw $10, 268508476($0) addi $10, $0, 0xffffff sw $10, 268508480($0) addi $10, $0, 0xffffff sw $10, 268508484($0) addi $10, $0, 0xffffff sw $10, 268508488($0) addi $10, $0, 0xffffff sw $10, 268508492($0) addi $10, $0, 0xffffff sw $10, 268508496($0) addi $10, $0, 0xffffff sw $10, 268508500($0) addi $10, $0, 0xffffff sw $10, 268508504($0) addi $10, $0, 0xffffff sw $10, 268508508($0) addi $10, $0, 0xfb821a sw $10, 268508512($0) addi $10, $0, 0xf2811c sw $10, 268508516($0) addi $10, $0, 0xdf7b19 sw $10, 268508520($0) addi $10, $0, 0xfc8015 sw $10, 268508524($0) addi $10, $0, 0xd67119 sw $10, 268508528($0) addi $10, $0, 0xf38010 sw $10, 268508532($0) addi $10, $0, 0xee8119 sw $10, 268508536($0) addi $10, $0, 0xe5c093 sw $10, 268508540($0) addi $10, $0, 0xfff8e8 sw $10, 268508544($0) addi $10, $0, 0xfff5f0 sw $10, 268508548($0) addi $10, $0, 0xfbfdff sw $10, 268508552($0) addi $10, $0, 0xfff8ff sw $10, 268508556($0) addi $10, $0, 0xc4a58a sw $10, 268508560($0) addi $10, $0, 0xee7d21 sw $10, 268508564($0) addi $10, $0, 0xfa7a20 sw $10, 268508568($0) addi $10, $0, 0xed6f03 sw $10, 268508572($0) addi $10, $0, 0xf97f1a sw $10, 268508576($0) addi $10, $0, 0xffffff sw $10, 268508580($0) addi $10, $0, 0xffffff sw $10, 268508584($0) addi $10, $0, 0xffffff sw $10, 268508588($0) addi $10, $0, 0xffffff sw $10, 268508592($0) addi $10, $0, 0xffffff sw $10, 268508596($0) addi $10, $0, 0xffffff sw $10, 268508600($0) addi $10, $0, 0xffffff sw $10, 268508604($0) addi $10, $0, 0xffffff sw $10, 268508608($0) addi $10, $0, 0xffffff sw $10, 268508612($0) addi $10, $0, 0xffffff sw $10, 268508616($0) addi $10, $0, 0xffffff sw $10, 268508620($0) addi $10, $0, 0xffffff sw $10, 268508624($0) addi $10, $0, 0xffffff sw $10, 268508628($0) addi $10, $0, 0xffffff sw $10, 268508632($0) addi $10, $0, 0xffffff sw $10, 268508636($0) addi $10, $0, 0xffffff sw $10, 268508640($0) addi $10, $0, 0xffffff sw $10, 268508644($0) addi $10, $0, 0xffffff sw $10, 268508648($0) addi $10, $0, 0xffffff sw $10, 268508652($0) addi $10, $0, 0xffffff sw $10, 268508656($0) addi $10, $0, 0xffffff sw $10, 268508660($0) addi $10, $0, 0xffffff sw $10, 268508664($0) addi $10, $0, 0x00d800 sw $10, 268508668($0) addi $10, $0, 0x00d800 sw $10, 268508672($0) addi $10, $0, 0xffffff sw $10, 268508676($0) addi $10, $0, 0xffffff sw $10, 268508680($0) addi $10, $0, 0xffffff sw $10, 268508684($0) addi $10, $0, 0xffffff sw $10, 268508688($0) addi $10, $0, 0xffffff sw $10, 268508692($0) addi $10, $0, 0xffffff sw $10, 268508696($0) addi $10, $0, 0xffffff sw $10, 268508700($0) addi $10, $0, 0xffffff sw $10, 268508704($0) addi $10, $0, 0xffffff sw $10, 268508708($0) addi $10, $0, 0xffffff sw $10, 268508712($0) addi $10, $0, 0xffffff sw $10, 268508716($0) addi $10, $0, 0xffffff sw $10, 268508720($0) addi $10, $0, 0xffffff sw $10, 268508724($0) addi $10, $0, 0xffffff sw $10, 268508728($0) addi $10, $0, 0xffffff sw $10, 268508732($0) addi $10, $0, 0xffffff sw $10, 268508736($0) addi $10, $0, 0xffffff sw $10, 268508740($0) addi $10, $0, 0xffffff sw $10, 268508744($0) addi $10, $0, 0xffffff sw $10, 268508748($0) addi $10, $0, 0xffffff sw $10, 268508752($0) addi $10, $0, 0xffffff sw $10, 268508756($0) addi $10, $0, 0xffffff sw $10, 268508760($0) addi $10, $0, 0xffffff sw $10, 268508764($0) addi $10, $0, 0xf38221 sw $10, 268508768($0) addi $10, $0, 0xec8225 sw $10, 268508772($0) addi $10, $0, 0xd97e23 sw $10, 268508776($0) addi $10, $0, 0xf4811b sw $10, 268508780($0) addi $10, $0, 0xd37726 sw $10, 268508784($0) addi $10, $0, 0xf77d20 sw $10, 268508788($0) addi $10, $0, 0xf97c1c sw $10, 268508792($0) addi $10, $0, 0xc97227 sw $10, 268508796($0) addi $10, $0, 0xe18531 sw $10, 268508800($0) addi $10, $0, 0xe5872c sw $10, 268508804($0) addi $10, $0, 0xde8328 sw $10, 268508808($0) addi $10, $0, 0xfe7928 sw $10, 268508812($0) addi $10, $0, 0xc68855 sw $10, 268508816($0) addi $10, $0, 0xf3f1e7 sw $10, 268508820($0) addi $10, $0, 0xfdfcff sw $10, 268508824($0) addi $10, $0, 0xca823e sw $10, 268508828($0) addi $10, $0, 0xf77b20 sw $10, 268508832($0) addi $10, $0, 0xffffff sw $10, 268508836($0) addi $10, $0, 0xffffff sw $10, 268508840($0) addi $10, $0, 0xffffff sw $10, 268508844($0) addi $10, $0, 0xffffff sw $10, 268508848($0) addi $10, $0, 0xffffff sw $10, 268508852($0) addi $10, $0, 0xffffff sw $10, 268508856($0) addi $10, $0, 0xffffff sw $10, 268508860($0) addi $10, $0, 0xffffff sw $10, 268508864($0) addi $10, $0, 0xffffff sw $10, 268508868($0) addi $10, $0, 0xffffff sw $10, 268508872($0) addi $10, $0, 0xffffff sw $10, 268508876($0) addi $10, $0, 0xffffff sw $10, 268508880($0) addi $10, $0, 0xffffff sw $10, 268508884($0) addi $10, $0, 0xffffff sw $10, 268508888($0) addi $10, $0, 0xffffff sw $10, 268508892($0) addi $10, $0, 0xffffff sw $10, 268508896($0) addi $10, $0, 0xffffff sw $10, 268508900($0) addi $10, $0, 0xffffff sw $10, 268508904($0) addi $10, $0, 0xffffff sw $10, 268508908($0) addi $10, $0, 0xffffff sw $10, 268508912($0) addi $10, $0, 0xffffff sw $10, 268508916($0) addi $10, $0, 0xffffff sw $10, 268508920($0) addi $10, $0, 0x00d800 sw $10, 268508924($0) addi $10, $0, 0x00d800 sw $10, 268508928($0) addi $10, $0, 0xffffff sw $10, 268508932($0) addi $10, $0, 0xffffff sw $10, 268508936($0) addi $10, $0, 0xffffff sw $10, 268508940($0) addi $10, $0, 0xffffff sw $10, 268508944($0) addi $10, $0, 0xffffff sw $10, 268508948($0) addi $10, $0, 0xffffff sw $10, 268508952($0) addi $10, $0, 0xffffff sw $10, 268508956($0) addi $10, $0, 0xffffff sw $10, 268508960($0) addi $10, $0, 0xffffff sw $10, 268508964($0) addi $10, $0, 0xffffff sw $10, 268508968($0) addi $10, $0, 0xffffff sw $10, 268508972($0) addi $10, $0, 0xffffff sw $10, 268508976($0) addi $10, $0, 0xffffff sw $10, 268508980($0) addi $10, $0, 0xffffff sw $10, 268508984($0) addi $10, $0, 0xffffff sw $10, 268508988($0) addi $10, $0, 0xffffff sw $10, 268508992($0) addi $10, $0, 0xffffff sw $10, 268508996($0) addi $10, $0, 0xffffff sw $10, 268509000($0) addi $10, $0, 0xffffff sw $10, 268509004($0) addi $10, $0, 0xffffff sw $10, 268509008($0) addi $10, $0, 0xffffff sw $10, 268509012($0) addi $10, $0, 0xffffff sw $10, 268509016($0) addi $10, $0, 0xffffff sw $10, 268509020($0) addi $10, $0, 0xfe790e sw $10, 268509024($0) addi $10, $0, 0xfa7c13 sw $10, 268509028($0) addi $10, $0, 0xe77814 sw $10, 268509032($0) addi $10, $0, 0xff7e0d sw $10, 268509036($0) addi $10, $0, 0xdd6d0f sw $10, 268509040($0) addi $10, $0, 0xfa7e1d sw $10, 268509044($0) addi $10, $0, 0xf97b17 sw $10, 268509048($0) addi $10, $0, 0xd66c11 sw $10, 268509052($0) addi $10, $0, 0xfd7d0c sw $10, 268509056($0) addi $10, $0, 0xfb7b06 sw $10, 268509060($0) addi $10, $0, 0xe78715 sw $10, 268509064($0) addi $10, $0, 0xff760c sw $10, 268509068($0) addi $10, $0, 0xbb8a50 sw $10, 268509072($0) addi $10, $0, 0xf2fff5 sw $10, 268509076($0) addi $10, $0, 0xf9f7f5 sw $10, 268509080($0) addi $10, $0, 0xd57910 sw $10, 268509084($0) addi $10, $0, 0xf8800d sw $10, 268509088($0) addi $10, $0, 0xffffff sw $10, 268509092($0) addi $10, $0, 0xffffff sw $10, 268509096($0) addi $10, $0, 0xffffff sw $10, 268509100($0) addi $10, $0, 0xffffff sw $10, 268509104($0) addi $10, $0, 0xffffff sw $10, 268509108($0) addi $10, $0, 0xffffff sw $10, 268509112($0) addi $10, $0, 0xffffff sw $10, 268509116($0) addi $10, $0, 0xffffff sw $10, 268509120($0) addi $10, $0, 0xffffff sw $10, 268509124($0) addi $10, $0, 0xffffff sw $10, 268509128($0) addi $10, $0, 0xffffff sw $10, 268509132($0) addi $10, $0, 0xffffff sw $10, 268509136($0) addi $10, $0, 0xffffff sw $10, 268509140($0) addi $10, $0, 0xffffff sw $10, 268509144($0) addi $10, $0, 0xffffff sw $10, 268509148($0) addi $10, $0, 0xffffff sw $10, 268509152($0) addi $10, $0, 0xffffff sw $10, 268509156($0) addi $10, $0, 0xffffff sw $10, 268509160($0) addi $10, $0, 0xffffff sw $10, 268509164($0) addi $10, $0, 0xffffff sw $10, 268509168($0) addi $10, $0, 0xffffff sw $10, 268509172($0) addi $10, $0, 0xffffff sw $10, 268509176($0) addi $10, $0, 0x00d800 sw $10, 268509180($0) addi $10, $0, 0x00d800 sw $10, 268509184($0) addi $10, $0, 0xffffff sw $10, 268509188($0) addi $10, $0, 0xffffff sw $10, 268509192($0) addi $10, $0, 0xffffff sw $10, 268509196($0) addi $10, $0, 0xffffff sw $10, 268509200($0) addi $10, $0, 0xffffff sw $10, 268509204($0) addi $10, $0, 0xffffff sw $10, 268509208($0) addi $10, $0, 0xffffff sw $10, 268509212($0) addi $10, $0, 0xffffff sw $10, 268509216($0) addi $10, $0, 0xffffff sw $10, 268509220($0) addi $10, $0, 0xffffff sw $10, 268509224($0) addi $10, $0, 0xffffff sw $10, 268509228($0) addi $10, $0, 0xffffff sw $10, 268509232($0) addi $10, $0, 0xffffff sw $10, 268509236($0) addi $10, $0, 0xffffff sw $10, 268509240($0) addi $10, $0, 0xffffff sw $10, 268509244($0) addi $10, $0, 0xffffff sw $10, 268509248($0) addi $10, $0, 0xffffff sw $10, 268509252($0) addi $10, $0, 0xffffff sw $10, 268509256($0) addi $10, $0, 0xffffff sw $10, 268509260($0) addi $10, $0, 0xffffff sw $10, 268509264($0) addi $10, $0, 0xffffff sw $10, 268509268($0) addi $10, $0, 0xffffff sw $10, 268509272($0) addi $10, $0, 0xffffff sw $10, 268509276($0) addi $10, $0, 0xda5e01 sw $10, 268509280($0) addi $10, $0, 0xd56409 sw $10, 268509284($0) addi $10, $0, 0xbb6620 sw $10, 268509288($0) addi $10, $0, 0xcd691b sw $10, 268509292($0) addi $10, $0, 0xb05d18 sw $10, 268509296($0) addi $10, $0, 0xd36200 sw $10, 268509300($0) addi $10, $0, 0xd76200 sw $10, 268509304($0) addi $10, $0, 0xb75200 sw $10, 268509308($0) addi $10, $0, 0xda6100 sw $10, 268509312($0) addi $10, $0, 0xd86203 sw $10, 268509316($0) addi $10, $0, 0xc96607 sw $10, 268509320($0) addi $10, $0, 0xe55601 sw $10, 268509324($0) addi $10, $0, 0x9e6b45 sw $10, 268509328($0) addi $10, $0, 0xd4c7b3 sw $10, 268509332($0) addi $10, $0, 0xd6bfc6 sw $10, 268509336($0) addi $10, $0, 0xb1601a sw $10, 268509340($0) addi $10, $0, 0xd85f01 sw $10, 268509344($0) addi $10, $0, 0xffffff sw $10, 268509348($0) addi $10, $0, 0xffffff sw $10, 268509352($0) addi $10, $0, 0xffffff sw $10, 268509356($0) addi $10, $0, 0xffffff sw $10, 268509360($0) addi $10, $0, 0xffffff sw $10, 268509364($0) addi $10, $0, 0xffffff sw $10, 268509368($0) addi $10, $0, 0xffffff sw $10, 268509372($0) addi $10, $0, 0xffffff sw $10, 268509376($0) addi $10, $0, 0xffffff sw $10, 268509380($0) addi $10, $0, 0xffffff sw $10, 268509384($0) addi $10, $0, 0xffffff sw $10, 268509388($0) addi $10, $0, 0xffffff sw $10, 268509392($0) addi $10, $0, 0xffffff sw $10, 268509396($0) addi $10, $0, 0xffffff sw $10, 268509400($0) addi $10, $0, 0xffffff sw $10, 268509404($0) addi $10, $0, 0xffffff sw $10, 268509408($0) addi $10, $0, 0xffffff sw $10, 268509412($0) addi $10, $0, 0xffffff sw $10, 268509416($0) addi $10, $0, 0xffffff sw $10, 268509420($0) addi $10, $0, 0xffffff sw $10, 268509424($0) addi $10, $0, 0xffffff sw $10, 268509428($0) addi $10, $0, 0xffffff sw $10, 268509432($0) addi $10, $0, 0x00d800 sw $10, 268509436($0) addi $10, $0, 0x00d800 sw $10, 268509440($0) addi $10, $0, 0xffffff sw $10, 268509444($0) addi $10, $0, 0xffffff sw $10, 268509448($0) addi $10, $0, 0xffffff sw $10, 268509452($0) addi $10, $0, 0xffffff sw $10, 268509456($0) addi $10, $0, 0xffffff sw $10, 268509460($0) addi $10, $0, 0xffffff sw $10, 268509464($0) addi $10, $0, 0xffffff sw $10, 268509468($0) addi $10, $0, 0xffffff sw $10, 268509472($0) addi $10, $0, 0xffffff sw $10, 268509476($0) addi $10, $0, 0xffffff sw $10, 268509480($0) addi $10, $0, 0xffffff sw $10, 268509484($0) addi $10, $0, 0xffffff sw $10, 268509488($0) addi $10, $0, 0xffffff sw $10, 268509492($0) addi $10, $0, 0xffffff sw $10, 268509496($0) addi $10, $0, 0xffffff sw $10, 268509500($0) addi $10, $0, 0xffffff sw $10, 268509504($0) addi $10, $0, 0xffffff sw $10, 268509508($0) addi $10, $0, 0xffffff sw $10, 268509512($0) addi $10, $0, 0xffffff sw $10, 268509516($0) addi $10, $0, 0xffffff sw $10, 268509520($0) addi $10, $0, 0xffffff sw $10, 268509524($0) addi $10, $0, 0xffffff sw $10, 268509528($0) addi $10, $0, 0xffffff sw $10, 268509532($0) addi $10, $0, 0xf87709 sw $10, 268509536($0) addi $10, $0, 0xef771f sw $10, 268509540($0) addi $10, $0, 0xecd9d5 sw $10, 268509544($0) addi $10, $0, 0xfcfbff sw $10, 268509548($0) addi $10, $0, 0xe6d3c7 sw $10, 268509552($0) addi $10, $0, 0xf77d10 sw $10, 268509556($0) addi $10, $0, 0xfc7712 sw $10, 268509560($0) addi $10, $0, 0xe76305 sw $10, 268509564($0) addi $10, $0, 0xfb7c10 sw $10, 268509568($0) addi $10, $0, 0xf97916 sw $10, 268509572($0) addi $10, $0, 0xfb760d sw $10, 268509576($0) addi $10, $0, 0xff760d sw $10, 268509580($0) addi $10, $0, 0xb9835a sw $10, 268509584($0) addi $10, $0, 0xf9fef3 sw $10, 268509588($0) addi $10, $0, 0xf5ffff sw $10, 268509592($0) addi $10, $0, 0xcd7410 sw $10, 268509596($0) addi $10, $0, 0xef7d0d sw $10, 268509600($0) addi $10, $0, 0xffffff sw $10, 268509604($0) addi $10, $0, 0xffffff sw $10, 268509608($0) addi $10, $0, 0xffffff sw $10, 268509612($0) addi $10, $0, 0xffffff sw $10, 268509616($0) addi $10, $0, 0xffffff sw $10, 268509620($0) addi $10, $0, 0xffffff sw $10, 268509624($0) addi $10, $0, 0xffffff sw $10, 268509628($0) addi $10, $0, 0xffffff sw $10, 268509632($0) addi $10, $0, 0xffffff sw $10, 268509636($0) addi $10, $0, 0xffffff sw $10, 268509640($0) addi $10, $0, 0xffffff sw $10, 268509644($0) addi $10, $0, 0xffffff sw $10, 268509648($0) addi $10, $0, 0xffffff sw $10, 268509652($0) addi $10, $0, 0xffffff sw $10, 268509656($0) addi $10, $0, 0xffffff sw $10, 268509660($0) addi $10, $0, 0xffffff sw $10, 268509664($0) addi $10, $0, 0xffffff sw $10, 268509668($0) addi $10, $0, 0xffffff sw $10, 268509672($0) addi $10, $0, 0xffffff sw $10, 268509676($0) addi $10, $0, 0xffffff sw $10, 268509680($0) addi $10, $0, 0xffffff sw $10, 268509684($0) addi $10, $0, 0xffffff sw $10, 268509688($0) addi $10, $0, 0x00d800 sw $10, 268509692($0) addi $10, $0, 0x00d800 sw $10, 268509696($0) addi $10, $0, 0xffffff sw $10, 268509700($0) addi $10, $0, 0xffffff sw $10, 268509704($0) addi $10, $0, 0xffffff sw $10, 268509708($0) addi $10, $0, 0xffffff sw $10, 268509712($0) addi $10, $0, 0xffffff sw $10, 268509716($0) addi $10, $0, 0xffffff sw $10, 268509720($0) addi $10, $0, 0xffffff sw $10, 268509724($0) addi $10, $0, 0xffffff sw $10, 268509728($0) addi $10, $0, 0xffffff sw $10, 268509732($0) addi $10, $0, 0xffffff sw $10, 268509736($0) addi $10, $0, 0xffffff sw $10, 268509740($0) addi $10, $0, 0xffffff sw $10, 268509744($0) addi $10, $0, 0xffffff sw $10, 268509748($0) addi $10, $0, 0xffffff sw $10, 268509752($0) addi $10, $0, 0xffffff sw $10, 268509756($0) addi $10, $0, 0xffffff sw $10, 268509760($0) addi $10, $0, 0xffffff sw $10, 268509764($0) addi $10, $0, 0xffffff sw $10, 268509768($0) addi $10, $0, 0xffffff sw $10, 268509772($0) addi $10, $0, 0xffffff sw $10, 268509776($0) addi $10, $0, 0xffffff sw $10, 268509780($0) addi $10, $0, 0xffffff sw $10, 268509784($0) addi $10, $0, 0xffffff sw $10, 268509788($0) addi $10, $0, 0xf77c0a sw $10, 268509792($0) addi $10, $0, 0xfa7a0c sw $10, 268509796($0) addi $10, $0, 0xeedec3 sw $10, 268509800($0) addi $10, $0, 0xf3faf5 sw $10, 268509804($0) addi $10, $0, 0xe4d2b0 sw $10, 268509808($0) addi $10, $0, 0xe7821d sw $10, 268509812($0) addi $10, $0, 0xeb7d21 sw $10, 268509816($0) addi $10, $0, 0xd46a0e sw $10, 268509820($0) addi $10, $0, 0xea821e sw $10, 268509824($0) addi $10, $0, 0xe78023 sw $10, 268509828($0) addi $10, $0, 0xe07f22 sw $10, 268509832($0) addi $10, $0, 0xfd7f1f sw $10, 268509836($0) addi $10, $0, 0xc78756 sw $10, 268509840($0) addi $10, $0, 0xfef8f0 sw $10, 268509844($0) addi $10, $0, 0xfff6ff sw $10, 268509848($0) addi $10, $0, 0xd5660e sw $10, 268509852($0) addi $10, $0, 0xf37e11 sw $10, 268509856($0) addi $10, $0, 0xffffff sw $10, 268509860($0) addi $10, $0, 0xffffff sw $10, 268509864($0) addi $10, $0, 0xffffff sw $10, 268509868($0) addi $10, $0, 0xffffff sw $10, 268509872($0) addi $10, $0, 0xffffff sw $10, 268509876($0) addi $10, $0, 0xffffff sw $10, 268509880($0) addi $10, $0, 0xffffff sw $10, 268509884($0) addi $10, $0, 0xffffff sw $10, 268509888($0) addi $10, $0, 0xffffff sw $10, 268509892($0) addi $10, $0, 0xffffff sw $10, 268509896($0) addi $10, $0, 0xffffff sw $10, 268509900($0) addi $10, $0, 0xffffff sw $10, 268509904($0) addi $10, $0, 0xffffff sw $10, 268509908($0) addi $10, $0, 0xffffff sw $10, 268509912($0) addi $10, $0, 0xffffff sw $10, 268509916($0) addi $10, $0, 0xffffff sw $10, 268509920($0) addi $10, $0, 0xffffff sw $10, 268509924($0) addi $10, $0, 0xffffff sw $10, 268509928($0) addi $10, $0, 0xffffff sw $10, 268509932($0) addi $10, $0, 0xffffff sw $10, 268509936($0) addi $10, $0, 0xffffff sw $10, 268509940($0) addi $10, $0, 0xffffff sw $10, 268509944($0) addi $10, $0, 0x00d800 sw $10, 268509948($0) addi $10, $0, 0x00d800 sw $10, 268509952($0) addi $10, $0, 0xffffff sw $10, 268509956($0) addi $10, $0, 0xffffff sw $10, 268509960($0) addi $10, $0, 0xffffff sw $10, 268509964($0) addi $10, $0, 0xffffff sw $10, 268509968($0) addi $10, $0, 0xffffff sw $10, 268509972($0) addi $10, $0, 0xffffff sw $10, 268509976($0) addi $10, $0, 0xffffff sw $10, 268509980($0) addi $10, $0, 0xffffff sw $10, 268509984($0) addi $10, $0, 0xffffff sw $10, 268509988($0) addi $10, $0, 0xffffff sw $10, 268509992($0) addi $10, $0, 0xffffff sw $10, 268509996($0) addi $10, $0, 0xffffff sw $10, 268510000($0) addi $10, $0, 0xffffff sw $10, 268510004($0) addi $10, $0, 0xffffff sw $10, 268510008($0) addi $10, $0, 0xffffff sw $10, 268510012($0) addi $10, $0, 0xffffff sw $10, 268510016($0) addi $10, $0, 0xffffff sw $10, 268510020($0) addi $10, $0, 0xffffff sw $10, 268510024($0) addi $10, $0, 0xffffff sw $10, 268510028($0) addi $10, $0, 0xffffff sw $10, 268510032($0) addi $10, $0, 0xffffff sw $10, 268510036($0) addi $10, $0, 0xffffff sw $10, 268510040($0) addi $10, $0, 0xffffff sw $10, 268510044($0) addi $10, $0, 0xf07001 sw $10, 268510048($0) addi $10, $0, 0xe5720c sw $10, 268510052($0) addi $10, $0, 0xbd7028 sw $10, 268510056($0) addi $10, $0, 0xcf7d2b sw $10, 268510060($0) addi $10, $0, 0xa96c27 sw $10, 268510064($0) addi $10, $0, 0xfae3c8 sw $10, 268510068($0) addi $10, $0, 0xfaebde sw $10, 268510072($0) addi $10, $0, 0xe2c3b5 sw $10, 268510076($0) addi $10, $0, 0xfae6cf sw $10, 268510080($0) addi $10, $0, 0xfae6d6 sw $10, 268510084($0) addi $10, $0, 0xf7ebde sw $10, 268510088($0) addi $10, $0, 0xfae7d3 sw $10, 268510092($0) addi $10, $0, 0xc3976f sw $10, 268510096($0) addi $10, $0, 0xcf751f sw $10, 268510100($0) addi $10, $0, 0xd1762c sw $10, 268510104($0) addi $10, $0, 0xcd6903 sw $10, 268510108($0) addi $10, $0, 0xe56f0d sw $10, 268510112($0) addi $10, $0, 0xffffff sw $10, 268510116($0) addi $10, $0, 0xffffff sw $10, 268510120($0) addi $10, $0, 0xffffff sw $10, 268510124($0) addi $10, $0, 0xffffff sw $10, 268510128($0) addi $10, $0, 0xffffff sw $10, 268510132($0) addi $10, $0, 0xffffff sw $10, 268510136($0) addi $10, $0, 0xffffff sw $10, 268510140($0) addi $10, $0, 0xffffff sw $10, 268510144($0) addi $10, $0, 0xffffff sw $10, 268510148($0) addi $10, $0, 0xffffff sw $10, 268510152($0) addi $10, $0, 0xffffff sw $10, 268510156($0) addi $10, $0, 0xffffff sw $10, 268510160($0) addi $10, $0, 0xffffff sw $10, 268510164($0) addi $10, $0, 0xffffff sw $10, 268510168($0) addi $10, $0, 0xffffff sw $10, 268510172($0) addi $10, $0, 0xffffff sw $10, 268510176($0) addi $10, $0, 0xffffff sw $10, 268510180($0) addi $10, $0, 0xffffff sw $10, 268510184($0) addi $10, $0, 0xffffff sw $10, 268510188($0) addi $10, $0, 0xffffff sw $10, 268510192($0) addi $10, $0, 0xffffff sw $10, 268510196($0) addi $10, $0, 0xffffff sw $10, 268510200($0) addi $10, $0, 0x00d800 sw $10, 268510204($0) addi $10, $0, 0x00d800 sw $10, 268510208($0) addi $10, $0, 0xffffff sw $10, 268510212($0) addi $10, $0, 0xffffff sw $10, 268510216($0) addi $10, $0, 0xffffff sw $10, 268510220($0) addi $10, $0, 0xffffff sw $10, 268510224($0) addi $10, $0, 0xffffff sw $10, 268510228($0) addi $10, $0, 0xffffff sw $10, 268510232($0) addi $10, $0, 0xffffff sw $10, 268510236($0) addi $10, $0, 0xffffff sw $10, 268510240($0) addi $10, $0, 0xffffff sw $10, 268510244($0) addi $10, $0, 0xffffff sw $10, 268510248($0) addi $10, $0, 0xffffff sw $10, 268510252($0) addi $10, $0, 0xffffff sw $10, 268510256($0) addi $10, $0, 0xffffff sw $10, 268510260($0) addi $10, $0, 0xffffff sw $10, 268510264($0) addi $10, $0, 0xffffff sw $10, 268510268($0) addi $10, $0, 0xffffff sw $10, 268510272($0) addi $10, $0, 0xffffff sw $10, 268510276($0) addi $10, $0, 0xffffff sw $10, 268510280($0) addi $10, $0, 0xffffff sw $10, 268510284($0) addi $10, $0, 0xffffff sw $10, 268510288($0) addi $10, $0, 0xffffff sw $10, 268510292($0) addi $10, $0, 0xffffff sw $10, 268510296($0) addi $10, $0, 0xffffff sw $10, 268510300($0) addi $10, $0, 0xfa7c18 sw $10, 268510304($0) addi $10, $0, 0xe8802d sw $10, 268510308($0) addi $10, $0, 0xe8741e sw $10, 268510312($0) addi $10, $0, 0xff7a09 sw $10, 268510316($0) addi $10, $0, 0xc56b29 sw $10, 268510320($0) addi $10, $0, 0xfaf9ef sw $10, 268510324($0) addi $10, $0, 0xfcfbfd sw $10, 268510328($0) addi $10, $0, 0xd5d5d9 sw $10, 268510332($0) addi $10, $0, 0xf5faf2 sw $10, 268510336($0) addi $10, $0, 0xf4faf5 sw $10, 268510340($0) addi $10, $0, 0xe9f9f4 sw $10, 268510344($0) addi $10, $0, 0xfdfbf6 sw $10, 268510348($0) addi $10, $0, 0xcba075 sw $10, 268510352($0) addi $10, $0, 0xfe7d04 sw $10, 268510356($0) addi $10, $0, 0xfe7b12 sw $10, 268510360($0) addi $10, $0, 0xcb7c1e sw $10, 268510364($0) addi $10, $0, 0xf48203 sw $10, 268510368($0) addi $10, $0, 0xffffff sw $10, 268510372($0) addi $10, $0, 0xffffff sw $10, 268510376($0) addi $10, $0, 0xffffff sw $10, 268510380($0) addi $10, $0, 0xffffff sw $10, 268510384($0) addi $10, $0, 0xffffff sw $10, 268510388($0) addi $10, $0, 0xffffff sw $10, 268510392($0) addi $10, $0, 0xffffff sw $10, 268510396($0) addi $10, $0, 0xffffff sw $10, 268510400($0) addi $10, $0, 0xffffff sw $10, 268510404($0) addi $10, $0, 0xffffff sw $10, 268510408($0) addi $10, $0, 0xffffff sw $10, 268510412($0) addi $10, $0, 0xffffff sw $10, 268510416($0) addi $10, $0, 0xffffff sw $10, 268510420($0) addi $10, $0, 0xffffff sw $10, 268510424($0) addi $10, $0, 0xffffff sw $10, 268510428($0) addi $10, $0, 0xffffff sw $10, 268510432($0) addi $10, $0, 0xffffff sw $10, 268510436($0) addi $10, $0, 0xffffff sw $10, 268510440($0) addi $10, $0, 0xffffff sw $10, 268510444($0) addi $10, $0, 0xffffff sw $10, 268510448($0) addi $10, $0, 0xffffff sw $10, 268510452($0) addi $10, $0, 0xffffff sw $10, 268510456($0) addi $10, $0, 0x00d800 sw $10, 268510460($0) addi $10, $0, 0x00d800 sw $10, 268510464($0) addi $10, $0, 0xffffff sw $10, 268510468($0) addi $10, $0, 0xffffff sw $10, 268510472($0) addi $10, $0, 0xffffff sw $10, 268510476($0) addi $10, $0, 0xffffff sw $10, 268510480($0) addi $10, $0, 0xffffff sw $10, 268510484($0) addi $10, $0, 0xffffff sw $10, 268510488($0) addi $10, $0, 0xffffff sw $10, 268510492($0) addi $10, $0, 0xffffff sw $10, 268510496($0) addi $10, $0, 0xffffff sw $10, 268510500($0) addi $10, $0, 0xffffff sw $10, 268510504($0) addi $10, $0, 0xffffff sw $10, 268510508($0) addi $10, $0, 0xffffff sw $10, 268510512($0) addi $10, $0, 0xffffff sw $10, 268510516($0) addi $10, $0, 0xffffff sw $10, 268510520($0) addi $10, $0, 0xffffff sw $10, 268510524($0) addi $10, $0, 0xffffff sw $10, 268510528($0) addi $10, $0, 0xffffff sw $10, 268510532($0) addi $10, $0, 0xffffff sw $10, 268510536($0) addi $10, $0, 0xffffff sw $10, 268510540($0) addi $10, $0, 0xffffff sw $10, 268510544($0) addi $10, $0, 0xffffff sw $10, 268510548($0) addi $10, $0, 0xffffff sw $10, 268510552($0) addi $10, $0, 0xffffff sw $10, 268510556($0) addi $10, $0, 0xe3750c sw $10, 268510560($0) addi $10, $0, 0xe7760f sw $10, 268510564($0) addi $10, $0, 0xd26e16 sw $10, 268510568($0) addi $10, $0, 0xe57618 sw $10, 268510572($0) addi $10, $0, 0xb46a33 sw $10, 268510576($0) addi $10, $0, 0xfeead3 sw $10, 268510580($0) addi $10, $0, 0xfde8df sw $10, 268510584($0) addi $10, $0, 0xdbc9bb sw $10, 268510588($0) addi $10, $0, 0xfeefd6 sw $10, 268510592($0) addi $10, $0, 0xfbecd7 sw $10, 268510596($0) addi $10, $0, 0xf5ecdd sw $10, 268510600($0) addi $10, $0, 0xffebe2 sw $10, 268510604($0) addi $10, $0, 0xd09975 sw $10, 268510608($0) addi $10, $0, 0xd9761e sw $10, 268510612($0) addi $10, $0, 0xe57321 sw $10, 268510616($0) addi $10, $0, 0xce6e0f sw $10, 268510620($0) addi $10, $0, 0xe66f12 sw $10, 268510624($0) addi $10, $0, 0xffffff sw $10, 268510628($0) addi $10, $0, 0xffffff sw $10, 268510632($0) addi $10, $0, 0xffffff sw $10, 268510636($0) addi $10, $0, 0xffffff sw $10, 268510640($0) addi $10, $0, 0xffffff sw $10, 268510644($0) addi $10, $0, 0xffffff sw $10, 268510648($0) addi $10, $0, 0xffffff sw $10, 268510652($0) addi $10, $0, 0xffffff sw $10, 268510656($0) addi $10, $0, 0xffffff sw $10, 268510660($0) addi $10, $0, 0xffffff sw $10, 268510664($0) addi $10, $0, 0xffffff sw $10, 268510668($0) addi $10, $0, 0xffffff sw $10, 268510672($0) addi $10, $0, 0xffffff sw $10, 268510676($0) addi $10, $0, 0xffffff sw $10, 268510680($0) addi $10, $0, 0xffffff sw $10, 268510684($0) addi $10, $0, 0xffffff sw $10, 268510688($0) addi $10, $0, 0xffffff sw $10, 268510692($0) addi $10, $0, 0xffffff sw $10, 268510696($0) addi $10, $0, 0xffffff sw $10, 268510700($0) addi $10, $0, 0xffffff sw $10, 268510704($0) addi $10, $0, 0xffffff sw $10, 268510708($0) addi $10, $0, 0xffffff sw $10, 268510712($0) addi $10, $0, 0x00d800 sw $10, 268510716($0) addi $10, $0, 0x00d800 sw $10, 268510720($0) addi $10, $0, 0xffffff sw $10, 268510724($0) addi $10, $0, 0xffffff sw $10, 268510728($0) addi $10, $0, 0xffffff sw $10, 268510732($0) addi $10, $0, 0xffffff sw $10, 268510736($0) addi $10, $0, 0xffffff sw $10, 268510740($0) addi $10, $0, 0xffffff sw $10, 268510744($0) addi $10, $0, 0xffffff sw $10, 268510748($0) addi $10, $0, 0xffffff sw $10, 268510752($0) addi $10, $0, 0xffffff sw $10, 268510756($0) addi $10, $0, 0xffffff sw $10, 268510760($0) addi $10, $0, 0xffffff sw $10, 268510764($0) addi $10, $0, 0xffffff sw $10, 268510768($0) addi $10, $0, 0xffffff sw $10, 268510772($0) addi $10, $0, 0xffffff sw $10, 268510776($0) addi $10, $0, 0xffffff sw $10, 268510780($0) addi $10, $0, 0xffffff sw $10, 268510784($0) addi $10, $0, 0xffffff sw $10, 268510788($0) addi $10, $0, 0xffffff sw $10, 268510792($0) addi $10, $0, 0xffffff sw $10, 268510796($0) addi $10, $0, 0xffffff sw $10, 268510800($0) addi $10, $0, 0xffffff sw $10, 268510804($0) addi $10, $0, 0xffffff sw $10, 268510808($0) addi $10, $0, 0xffffff sw $10, 268510812($0) addi $10, $0, 0xfd7811 sw $10, 268510816($0) addi $10, $0, 0xfa771a sw $10, 268510820($0) addi $10, $0, 0xec7214 sw $10, 268510824($0) addi $10, $0, 0xff7212 sw $10, 268510828($0) addi $10, $0, 0xdd690d sw $10, 268510832($0) addi $10, $0, 0xf08106 sw $10, 268510836($0) addi $10, $0, 0xfc7019 sw $10, 268510840($0) addi $10, $0, 0xd46907 sw $10, 268510844($0) addi $10, $0, 0xf77a08 sw $10, 268510848($0) addi $10, $0, 0xf57b24 sw $10, 268510852($0) addi $10, $0, 0xda8a2e sw $10, 268510856($0) addi $10, $0, 0xfb761b sw $10, 268510860($0) addi $10, $0, 0xd46105 sw $10, 268510864($0) addi $10, $0, 0xec7a11 sw $10, 268510868($0) addi $10, $0, 0xeb7d1a sw $10, 268510872($0) addi $10, $0, 0xd7700d sw $10, 268510876($0) addi $10, $0, 0xfc780b sw $10, 268510880($0) addi $10, $0, 0xffffff sw $10, 268510884($0) addi $10, $0, 0xffffff sw $10, 268510888($0) addi $10, $0, 0xffffff sw $10, 268510892($0) addi $10, $0, 0xffffff sw $10, 268510896($0) addi $10, $0, 0xffffff sw $10, 268510900($0) addi $10, $0, 0xffffff sw $10, 268510904($0) addi $10, $0, 0xffffff sw $10, 268510908($0) addi $10, $0, 0xffffff sw $10, 268510912($0) addi $10, $0, 0xffffff sw $10, 268510916($0) addi $10, $0, 0xffffff sw $10, 268510920($0) addi $10, $0, 0xffffff sw $10, 268510924($0) addi $10, $0, 0xffffff sw $10, 268510928($0) addi $10, $0, 0xffffff sw $10, 268510932($0) addi $10, $0, 0xffffff sw $10, 268510936($0) addi $10, $0, 0xffffff sw $10, 268510940($0) addi $10, $0, 0xffffff sw $10, 268510944($0) addi $10, $0, 0xffffff sw $10, 268510948($0) addi $10, $0, 0xffffff sw $10, 268510952($0) addi $10, $0, 0xffffff sw $10, 268510956($0) addi $10, $0, 0xffffff sw $10, 268510960($0) addi $10, $0, 0xffffff sw $10, 268510964($0) addi $10, $0, 0xffffff sw $10, 268510968($0) addi $10, $0, 0x00d800 sw $10, 268510972($0) addi $10, $0, 0x00d800 sw $10, 268510976($0) addi $10, $0, 0xffffff sw $10, 268510980($0) addi $10, $0, 0xffffff sw $10, 268510984($0) addi $10, $0, 0xffffff sw $10, 268510988($0) addi $10, $0, 0xffffff sw $10, 268510992($0) addi $10, $0, 0xffffff sw $10, 268510996($0) addi $10, $0, 0xffffff sw $10, 268511000($0) addi $10, $0, 0xffffff sw $10, 268511004($0) addi $10, $0, 0xffffff sw $10, 268511008($0) addi $10, $0, 0xffffff sw $10, 268511012($0) addi $10, $0, 0xffffff sw $10, 268511016($0) addi $10, $0, 0xffffff sw $10, 268511020($0) addi $10, $0, 0xffffff sw $10, 268511024($0) addi $10, $0, 0xffffff sw $10, 268511028($0) addi $10, $0, 0xffffff sw $10, 268511032($0) addi $10, $0, 0xffffff sw $10, 268511036($0) addi $10, $0, 0xffffff sw $10, 268511040($0) addi $10, $0, 0xffffff sw $10, 268511044($0) addi $10, $0, 0xffffff sw $10, 268511048($0) addi $10, $0, 0xffffff sw $10, 268511052($0) addi $10, $0, 0xffffff sw $10, 268511056($0) addi $10, $0, 0xffffff sw $10, 268511060($0) addi $10, $0, 0xffffff sw $10, 268511064($0) addi $10, $0, 0xffffff sw $10, 268511068($0) addi $10, $0, 0xf17906 sw $10, 268511072($0) addi $10, $0, 0xf57e15 sw $10, 268511076($0) addi $10, $0, 0xe1740c sw $10, 268511080($0) addi $10, $0, 0xfc7b0e sw $10, 268511084($0) addi $10, $0, 0xd46d05 sw $10, 268511088($0) addi $10, $0, 0xee810e sw $10, 268511092($0) addi $10, $0, 0xfe7a26 sw $10, 268511096($0) addi $10, $0, 0xd57311 sw $10, 268511100($0) addi $10, $0, 0xf17d12 sw $10, 268511104($0) addi $10, $0, 0xf5832f sw $10, 268511108($0) addi $10, $0, 0xd7862d sw $10, 268511112($0) addi $10, $0, 0xfc751f sw $10, 268511116($0) addi $10, $0, 0xcb5e04 sw $10, 268511120($0) addi $10, $0, 0xf88627 sw $10, 268511124($0) addi $10, $0, 0xf9882e sw $10, 268511128($0) addi $10, $0, 0xe17e1f sw $10, 268511132($0) addi $10, $0, 0xf08919 sw $10, 268511136($0) addi $10, $0, 0xffffff sw $10, 268511140($0) addi $10, $0, 0xffffff sw $10, 268511144($0) addi $10, $0, 0xffffff sw $10, 268511148($0) addi $10, $0, 0xffffff sw $10, 268511152($0) addi $10, $0, 0xffffff sw $10, 268511156($0) addi $10, $0, 0xffffff sw $10, 268511160($0) addi $10, $0, 0xffffff sw $10, 268511164($0) addi $10, $0, 0xffffff sw $10, 268511168($0) addi $10, $0, 0xffffff sw $10, 268511172($0) addi $10, $0, 0xffffff sw $10, 268511176($0) addi $10, $0, 0xffffff sw $10, 268511180($0) addi $10, $0, 0xffffff sw $10, 268511184($0) addi $10, $0, 0xffffff sw $10, 268511188($0) addi $10, $0, 0xffffff sw $10, 268511192($0) addi $10, $0, 0xffffff sw $10, 268511196($0) addi $10, $0, 0xffffff sw $10, 268511200($0) addi $10, $0, 0xffffff sw $10, 268511204($0) addi $10, $0, 0xffffff sw $10, 268511208($0) addi $10, $0, 0xffffff sw $10, 268511212($0) addi $10, $0, 0xffffff sw $10, 268511216($0) addi $10, $0, 0xffffff sw $10, 268511220($0) addi $10, $0, 0xffffff sw $10, 268511224($0) addi $10, $0, 0x00d800 sw $10, 268511228($0) addi $10, $0, 0x00d800 sw $10, 268511232($0) addi $10, $0, 0xffffff sw $10, 268511236($0) addi $10, $0, 0xffffff sw $10, 268511240($0) addi $10, $0, 0xffffff sw $10, 268511244($0) addi $10, $0, 0xffffff sw $10, 268511248($0) addi $10, $0, 0xffffff sw $10, 268511252($0) addi $10, $0, 0xffffff sw $10, 268511256($0) addi $10, $0, 0xffffff sw $10, 268511260($0) addi $10, $0, 0xffffff sw $10, 268511264($0) addi $10, $0, 0xffffff sw $10, 268511268($0) addi $10, $0, 0xffffff sw $10, 268511272($0) addi $10, $0, 0xffffff sw $10, 268511276($0) addi $10, $0, 0xffffff sw $10, 268511280($0) addi $10, $0, 0xffffff sw $10, 268511284($0) addi $10, $0, 0xffffff sw $10, 268511288($0) addi $10, $0, 0xffffff sw $10, 268511292($0) addi $10, $0, 0xffffff sw $10, 268511296($0) addi $10, $0, 0xffffff sw $10, 268511300($0) addi $10, $0, 0xffffff sw $10, 268511304($0) addi $10, $0, 0xffffff sw $10, 268511308($0) addi $10, $0, 0xffffff sw $10, 268511312($0) addi $10, $0, 0xffffff sw $10, 268511316($0) addi $10, $0, 0xffffff sw $10, 268511320($0) addi $10, $0, 0xffffff sw $10, 268511324($0) addi $10, $0, 0xc71d03 sw $10, 268511328($0) addi $10, $0, 0xbf1804 sw $10, 268511332($0) addi $10, $0, 0xb61c03 sw $10, 268511336($0) addi $10, $0, 0xc41904 sw $10, 268511340($0) addi $10, $0, 0xa91903 sw $10, 268511344($0) addi $10, $0, 0xba2a08 sw $10, 268511348($0) addi $10, $0, 0xd3311f sw $10, 268511352($0) addi $10, $0, 0x9d2206 sw $10, 268511356($0) addi $10, $0, 0xcb3c1d sw $10, 268511360($0) addi $10, $0, 0xc53829 sw $10, 268511364($0) addi $10, $0, 0xb14128 sw $10, 268511368($0) addi $10, $0, 0xbb1b07 sw $10, 268511372($0) addi $10, $0, 0xa93310 sw $10, 268511376($0) addi $10, $0, 0xb93418 sw $10, 268511380($0) addi $10, $0, 0xad220a sw $10, 268511384($0) addi $10, $0, 0xa4280e sw $10, 268511388($0) addi $10, $0, 0xcb321b sw $10, 268511392($0) addi $10, $0, 0xffffff sw $10, 268511396($0) addi $10, $0, 0xffffff sw $10, 268511400($0) addi $10, $0, 0xffffff sw $10, 268511404($0) addi $10, $0, 0xffffff sw $10, 268511408($0) addi $10, $0, 0xffffff sw $10, 268511412($0) addi $10, $0, 0xffffff sw $10, 268511416($0) addi $10, $0, 0xffffff sw $10, 268511420($0) addi $10, $0, 0xffffff sw $10, 268511424($0) addi $10, $0, 0xffffff sw $10, 268511428($0) addi $10, $0, 0xffffff sw $10, 268511432($0) addi $10, $0, 0xffffff sw $10, 268511436($0) addi $10, $0, 0xffffff sw $10, 268511440($0) addi $10, $0, 0xffffff sw $10, 268511444($0) addi $10, $0, 0xffffff sw $10, 268511448($0) addi $10, $0, 0xffffff sw $10, 268511452($0) addi $10, $0, 0xffffff sw $10, 268511456($0) addi $10, $0, 0xffffff sw $10, 268511460($0) addi $10, $0, 0xffffff sw $10, 268511464($0) addi $10, $0, 0xffffff sw $10, 268511468($0) addi $10, $0, 0xffffff sw $10, 268511472($0) addi $10, $0, 0xffffff sw $10, 268511476($0) addi $10, $0, 0xffffff sw $10, 268511480($0) addi $10, $0, 0x00d800 sw $10, 268511484($0) addi $10, $0, 0x00d800 sw $10, 268511488($0) addi $10, $0, 0xffffff sw $10, 268511492($0) addi $10, $0, 0xffffff sw $10, 268511496($0) addi $10, $0, 0xffffff sw $10, 268511500($0) addi $10, $0, 0xffffff sw $10, 268511504($0) addi $10, $0, 0xffffff sw $10, 268511508($0) addi $10, $0, 0xffffff sw $10, 268511512($0) addi $10, $0, 0xffffff sw $10, 268511516($0) addi $10, $0, 0xffffff sw $10, 268511520($0) addi $10, $0, 0xffffff sw $10, 268511524($0) addi $10, $0, 0xffffff sw $10, 268511528($0) addi $10, $0, 0xffffff sw $10, 268511532($0) addi $10, $0, 0xffffff sw $10, 268511536($0) addi $10, $0, 0xffffff sw $10, 268511540($0) addi $10, $0, 0xffffff sw $10, 268511544($0) addi $10, $0, 0xffffff sw $10, 268511548($0) addi $10, $0, 0xffffff sw $10, 268511552($0) addi $10, $0, 0xffffff sw $10, 268511556($0) addi $10, $0, 0xffffff sw $10, 268511560($0) addi $10, $0, 0xffffff sw $10, 268511564($0) addi $10, $0, 0xffffff sw $10, 268511568($0) addi $10, $0, 0xffffff sw $10, 268511572($0) addi $10, $0, 0xffffff sw $10, 268511576($0) addi $10, $0, 0xffffff sw $10, 268511580($0) addi $10, $0, 0xffffff sw $10, 268511584($0) addi $10, $0, 0xffffff sw $10, 268511588($0) addi $10, $0, 0xffffff sw $10, 268511592($0) addi $10, $0, 0xffffff sw $10, 268511596($0) addi $10, $0, 0xffffff sw $10, 268511600($0) addi $10, $0, 0xffffff sw $10, 268511604($0) addi $10, $0, 0xffffff sw $10, 268511608($0) addi $10, $0, 0xffffff sw $10, 268511612($0) addi $10, $0, 0xffffff sw $10, 268511616($0) addi $10, $0, 0xffffff sw $10, 268511620($0) addi $10, $0, 0xffffff sw $10, 268511624($0) addi $10, $0, 0xffffff sw $10, 268511628($0) addi $10, $0, 0xffffff sw $10, 268511632($0) addi $10, $0, 0xffffff sw $10, 268511636($0) addi $10, $0, 0xffffff sw $10, 268511640($0) addi $10, $0, 0xffffff sw $10, 268511644($0) addi $10, $0, 0xffffff sw $10, 268511648($0) addi $10, $0, 0xffffff sw $10, 268511652($0) addi $10, $0, 0xffffff sw $10, 268511656($0) addi $10, $0, 0xffffff sw $10, 268511660($0) addi $10, $0, 0xffffff sw $10, 268511664($0) addi $10, $0, 0xffffff sw $10, 268511668($0) addi $10, $0, 0xffffff sw $10, 268511672($0) addi $10, $0, 0xffffff sw $10, 268511676($0) addi $10, $0, 0xffffff sw $10, 268511680($0) addi $10, $0, 0xffffff sw $10, 268511684($0) addi $10, $0, 0xffffff sw $10, 268511688($0) addi $10, $0, 0xffffff sw $10, 268511692($0) addi $10, $0, 0xffffff sw $10, 268511696($0) addi $10, $0, 0xffffff sw $10, 268511700($0) addi $10, $0, 0xffffff sw $10, 268511704($0) addi $10, $0, 0xffffff sw $10, 268511708($0) addi $10, $0, 0xffffff sw $10, 268511712($0) addi $10, $0, 0xffffff sw $10, 268511716($0) addi $10, $0, 0xffffff sw $10, 268511720($0) addi $10, $0, 0xffffff sw $10, 268511724($0) addi $10, $0, 0xffffff sw $10, 268511728($0) addi $10, $0, 0xffffff sw $10, 268511732($0) addi $10, $0, 0xffffff sw $10, 268511736($0) addi $10, $0, 0x00d800 sw $10, 268511740($0) addi $10, $0, 0x00d800 sw $10, 268511744($0) addi $10, $0, 0xffffff sw $10, 268511748($0) addi $10, $0, 0xffffff sw $10, 268511752($0) addi $10, $0, 0xffffff sw $10, 268511756($0) addi $10, $0, 0xffffff sw $10, 268511760($0) addi $10, $0, 0xffffff sw $10, 268511764($0) addi $10, $0, 0xffffff sw $10, 268511768($0) addi $10, $0, 0xffffff sw $10, 268511772($0) addi $10, $0, 0xffffff sw $10, 268511776($0) addi $10, $0, 0xffffff sw $10, 268511780($0) addi $10, $0, 0xffffff sw $10, 268511784($0) addi $10, $0, 0xffffff sw $10, 268511788($0) addi $10, $0, 0xffffff sw $10, 268511792($0) addi $10, $0, 0xffffff sw $10, 268511796($0) addi $10, $0, 0xffffff sw $10, 268511800($0) addi $10, $0, 0xffffff sw $10, 268511804($0) addi $10, $0, 0xffffff sw $10, 268511808($0) addi $10, $0, 0xffffff sw $10, 268511812($0) addi $10, $0, 0xffffff sw $10, 268511816($0) addi $10, $0, 0xffffff sw $10, 268511820($0) addi $10, $0, 0xffffff sw $10, 268511824($0) addi $10, $0, 0xffffff sw $10, 268511828($0) addi $10, $0, 0xffffff sw $10, 268511832($0) addi $10, $0, 0xffffff sw $10, 268511836($0) addi $10, $0, 0xffffff sw $10, 268511840($0) addi $10, $0, 0xffffff sw $10, 268511844($0) addi $10, $0, 0xffffff sw $10, 268511848($0) addi $10, $0, 0xffffff sw $10, 268511852($0) addi $10, $0, 0xffffff sw $10, 268511856($0) addi $10, $0, 0xffffff sw $10, 268511860($0) addi $10, $0, 0xffffff sw $10, 268511864($0) addi $10, $0, 0xffffff sw $10, 268511868($0) addi $10, $0, 0xffffff sw $10, 268511872($0) addi $10, $0, 0xffffff sw $10, 268511876($0) addi $10, $0, 0xffffff sw $10, 268511880($0) addi $10, $0, 0xffffff sw $10, 268511884($0) addi $10, $0, 0xffffff sw $10, 268511888($0) addi $10, $0, 0xffffff sw $10, 268511892($0) addi $10, $0, 0xffffff sw $10, 268511896($0) addi $10, $0, 0xffffff sw $10, 268511900($0) addi $10, $0, 0xffffff sw $10, 268511904($0) addi $10, $0, 0xffffff sw $10, 268511908($0) addi $10, $0, 0xffffff sw $10, 268511912($0) addi $10, $0, 0xffffff sw $10, 268511916($0) addi $10, $0, 0xffffff sw $10, 268511920($0) addi $10, $0, 0xffffff sw $10, 268511924($0) addi $10, $0, 0xffffff sw $10, 268511928($0) addi $10, $0, 0xffffff sw $10, 268511932($0) addi $10, $0, 0xffffff sw $10, 268511936($0) addi $10, $0, 0xffffff sw $10, 268511940($0) addi $10, $0, 0xffffff sw $10, 268511944($0) addi $10, $0, 0xffffff sw $10, 268511948($0) addi $10, $0, 0xffffff sw $10, 268511952($0) addi $10, $0, 0xffffff sw $10, 268511956($0) addi $10, $0, 0xffffff sw $10, 268511960($0) addi $10, $0, 0xffffff sw $10, 268511964($0) addi $10, $0, 0xffffff sw $10, 268511968($0) addi $10, $0, 0xffffff sw $10, 268511972($0) addi $10, $0, 0xffffff sw $10, 268511976($0) addi $10, $0, 0xffffff sw $10, 268511980($0) addi $10, $0, 0xffffff sw $10, 268511984($0) addi $10, $0, 0xffffff sw $10, 268511988($0) addi $10, $0, 0xffffff sw $10, 268511992($0) addi $10, $0, 0x00d800 sw $10, 268511996($0) addi $10, $0, 0x00d800 sw $10, 268512000($0) addi $10, $0, 0xffffff sw $10, 268512004($0) addi $10, $0, 0xffffff sw $10, 268512008($0) addi $10, $0, 0xffffff sw $10, 268512012($0) addi $10, $0, 0xffffff sw $10, 268512016($0) addi $10, $0, 0xffffff sw $10, 268512020($0) addi $10, $0, 0xffffff sw $10, 268512024($0) addi $10, $0, 0xffffff sw $10, 268512028($0) addi $10, $0, 0xffffff sw $10, 268512032($0) addi $10, $0, 0xffffff sw $10, 268512036($0) addi $10, $0, 0xffffff sw $10, 268512040($0) addi $10, $0, 0xffffff sw $10, 268512044($0) addi $10, $0, 0xffffff sw $10, 268512048($0) addi $10, $0, 0xffffff sw $10, 268512052($0) addi $10, $0, 0xffffff sw $10, 268512056($0) addi $10, $0, 0xffffff sw $10, 268512060($0) addi $10, $0, 0xffffff sw $10, 268512064($0) addi $10, $0, 0xffffff sw $10, 268512068($0) addi $10, $0, 0xffffff sw $10, 268512072($0) addi $10, $0, 0xffffff sw $10, 268512076($0) addi $10, $0, 0xffffff sw $10, 268512080($0) addi $10, $0, 0xffffff sw $10, 268512084($0) addi $10, $0, 0xffffff sw $10, 268512088($0) addi $10, $0, 0xffffff sw $10, 268512092($0) addi $10, $0, 0xffffff sw $10, 268512096($0) addi $10, $0, 0xffffff sw $10, 268512100($0) addi $10, $0, 0xffffff sw $10, 268512104($0) addi $10, $0, 0xffffff sw $10, 268512108($0) addi $10, $0, 0xffffff sw $10, 268512112($0) addi $10, $0, 0xffffff sw $10, 268512116($0) addi $10, $0, 0xffffff sw $10, 268512120($0) addi $10, $0, 0xffffff sw $10, 268512124($0) addi $10, $0, 0xffffff sw $10, 268512128($0) addi $10, $0, 0xffffff sw $10, 268512132($0) addi $10, $0, 0xffffff sw $10, 268512136($0) addi $10, $0, 0xffffff sw $10, 268512140($0) addi $10, $0, 0xffffff sw $10, 268512144($0) addi $10, $0, 0xffffff sw $10, 268512148($0) addi $10, $0, 0xffffff sw $10, 268512152($0) addi $10, $0, 0xffffff sw $10, 268512156($0) addi $10, $0, 0xffffff sw $10, 268512160($0) addi $10, $0, 0xffffff sw $10, 268512164($0) addi $10, $0, 0xffffff sw $10, 268512168($0) addi $10, $0, 0xffffff sw $10, 268512172($0) addi $10, $0, 0xffffff sw $10, 268512176($0) addi $10, $0, 0xffffff sw $10, 268512180($0) addi $10, $0, 0xffffff sw $10, 268512184($0) addi $10, $0, 0xffffff sw $10, 268512188($0) addi $10, $0, 0xffffff sw $10, 268512192($0) addi $10, $0, 0xffffff sw $10, 268512196($0) addi $10, $0, 0xffffff sw $10, 268512200($0) addi $10, $0, 0xffffff sw $10, 268512204($0) addi $10, $0, 0xffffff sw $10, 268512208($0) addi $10, $0, 0xffffff sw $10, 268512212($0) addi $10, $0, 0xffffff sw $10, 268512216($0) addi $10, $0, 0xffffff sw $10, 268512220($0) addi $10, $0, 0xffffff sw $10, 268512224($0) addi $10, $0, 0xffffff sw $10, 268512228($0) addi $10, $0, 0xffffff sw $10, 268512232($0) addi $10, $0, 0xffffff sw $10, 268512236($0) addi $10, $0, 0xffffff sw $10, 268512240($0) addi $10, $0, 0xffffff sw $10, 268512244($0) addi $10, $0, 0xffffff sw $10, 268512248($0) addi $10, $0, 0x00d800 sw $10, 268512252($0) addi $10, $0, 0x00d800 sw $10, 268512256($0) addi $10, $0, 0xffffff sw $10, 268512260($0) addi $10, $0, 0xffffff sw $10, 268512264($0) addi $10, $0, 0xffffff sw $10, 268512268($0) addi $10, $0, 0xffffff sw $10, 268512272($0) addi $10, $0, 0xffffff sw $10, 268512276($0) addi $10, $0, 0xffffff sw $10, 268512280($0) addi $10, $0, 0xffffff sw $10, 268512284($0) addi $10, $0, 0xffffff sw $10, 268512288($0) addi $10, $0, 0xffffff sw $10, 268512292($0) addi $10, $0, 0xffffff sw $10, 268512296($0) addi $10, $0, 0xffffff sw $10, 268512300($0) addi $10, $0, 0xffffff sw $10, 268512304($0) addi $10, $0, 0xffffff sw $10, 268512308($0) addi $10, $0, 0xffffff sw $10, 268512312($0) addi $10, $0, 0xffffff sw $10, 268512316($0) addi $10, $0, 0xffffff sw $10, 268512320($0) addi $10, $0, 0xffffff sw $10, 268512324($0) addi $10, $0, 0xffffff sw $10, 268512328($0) addi $10, $0, 0xffffff sw $10, 268512332($0) addi $10, $0, 0xffffff sw $10, 268512336($0) addi $10, $0, 0xffffff sw $10, 268512340($0) addi $10, $0, 0xffffff sw $10, 268512344($0) addi $10, $0, 0xffffff sw $10, 268512348($0) addi $10, $0, 0xffffff sw $10, 268512352($0) addi $10, $0, 0xffffff sw $10, 268512356($0) addi $10, $0, 0xffffff sw $10, 268512360($0) addi $10, $0, 0xffffff sw $10, 268512364($0) addi $10, $0, 0xffffff sw $10, 268512368($0) addi $10, $0, 0xffffff sw $10, 268512372($0) addi $10, $0, 0xffffff sw $10, 268512376($0) addi $10, $0, 0xffffff sw $10, 268512380($0) addi $10, $0, 0xffffff sw $10, 268512384($0) addi $10, $0, 0xffffff sw $10, 268512388($0) addi $10, $0, 0xffffff sw $10, 268512392($0) addi $10, $0, 0xffffff sw $10, 268512396($0) addi $10, $0, 0xffffff sw $10, 268512400($0) addi $10, $0, 0xffffff sw $10, 268512404($0) addi $10, $0, 0xffffff sw $10, 268512408($0) addi $10, $0, 0xffffff sw $10, 268512412($0) addi $10, $0, 0xffffff sw $10, 268512416($0) addi $10, $0, 0xffffff sw $10, 268512420($0) addi $10, $0, 0xffffff sw $10, 268512424($0) addi $10, $0, 0xffffff sw $10, 268512428($0) addi $10, $0, 0xffffff sw $10, 268512432($0) addi $10, $0, 0xffffff sw $10, 268512436($0) addi $10, $0, 0xffffff sw $10, 268512440($0) addi $10, $0, 0xffffff sw $10, 268512444($0) addi $10, $0, 0xffffff sw $10, 268512448($0) addi $10, $0, 0xffffff sw $10, 268512452($0) addi $10, $0, 0xffffff sw $10, 268512456($0) addi $10, $0, 0xffffff sw $10, 268512460($0) addi $10, $0, 0xffffff sw $10, 268512464($0) addi $10, $0, 0xffffff sw $10, 268512468($0) addi $10, $0, 0xffffff sw $10, 268512472($0) addi $10, $0, 0xffffff sw $10, 268512476($0) addi $10, $0, 0xffffff sw $10, 268512480($0) addi $10, $0, 0xffffff sw $10, 268512484($0) addi $10, $0, 0xffffff sw $10, 268512488($0) addi $10, $0, 0xffffff sw $10, 268512492($0) addi $10, $0, 0xffffff sw $10, 268512496($0) addi $10, $0, 0xffffff sw $10, 268512500($0) addi $10, $0, 0xffffff sw $10, 268512504($0) addi $10, $0, 0x00d800 sw $10, 268512508($0) addi $10, $0, 0x00d800 sw $10, 268512512($0) addi $10, $0, 0xffffff sw $10, 268512516($0) addi $10, $0, 0xffffff sw $10, 268512520($0) addi $10, $0, 0xffffff sw $10, 268512524($0) addi $10, $0, 0xffffff sw $10, 268512528($0) addi $10, $0, 0xffffff sw $10, 268512532($0) addi $10, $0, 0xffffff sw $10, 268512536($0) addi $10, $0, 0xffffff sw $10, 268512540($0) addi $10, $0, 0xffffff sw $10, 268512544($0) addi $10, $0, 0xffffff sw $10, 268512548($0) addi $10, $0, 0xffffff sw $10, 268512552($0) addi $10, $0, 0xffffff sw $10, 268512556($0) addi $10, $0, 0xffffff sw $10, 268512560($0) addi $10, $0, 0xffffff sw $10, 268512564($0) addi $10, $0, 0xffffff sw $10, 268512568($0) addi $10, $0, 0xffffff sw $10, 268512572($0) addi $10, $0, 0xffffff sw $10, 268512576($0) addi $10, $0, 0xffffff sw $10, 268512580($0) addi $10, $0, 0xffffff sw $10, 268512584($0) addi $10, $0, 0xffffff sw $10, 268512588($0) addi $10, $0, 0xffffff sw $10, 268512592($0) addi $10, $0, 0xffffff sw $10, 268512596($0) addi $10, $0, 0xffffff sw $10, 268512600($0) addi $10, $0, 0xffffff sw $10, 268512604($0) addi $10, $0, 0xffffff sw $10, 268512608($0) addi $10, $0, 0xffffff sw $10, 268512612($0) addi $10, $0, 0xffffff sw $10, 268512616($0) addi $10, $0, 0xffffff sw $10, 268512620($0) addi $10, $0, 0xffffff sw $10, 268512624($0) addi $10, $0, 0xffffff sw $10, 268512628($0) addi $10, $0, 0xffffff sw $10, 268512632($0) addi $10, $0, 0xffffff sw $10, 268512636($0) addi $10, $0, 0xffffff sw $10, 268512640($0) addi $10, $0, 0xffffff sw $10, 268512644($0) addi $10, $0, 0xffffff sw $10, 268512648($0) addi $10, $0, 0xffffff sw $10, 268512652($0) addi $10, $0, 0xffffff sw $10, 268512656($0) addi $10, $0, 0xffffff sw $10, 268512660($0) addi $10, $0, 0xffffff sw $10, 268512664($0) addi $10, $0, 0xffffff sw $10, 268512668($0) addi $10, $0, 0xffffff sw $10, 268512672($0) addi $10, $0, 0xffffff sw $10, 268512676($0) addi $10, $0, 0xffffff sw $10, 268512680($0) addi $10, $0, 0xffffff sw $10, 268512684($0) addi $10, $0, 0xffffff sw $10, 268512688($0) addi $10, $0, 0xffffff sw $10, 268512692($0) addi $10, $0, 0xffffff sw $10, 268512696($0) addi $10, $0, 0xffffff sw $10, 268512700($0) addi $10, $0, 0xffffff sw $10, 268512704($0) addi $10, $0, 0xffffff sw $10, 268512708($0) addi $10, $0, 0xffffff sw $10, 268512712($0) addi $10, $0, 0xffffff sw $10, 268512716($0) addi $10, $0, 0xffffff sw $10, 268512720($0) addi $10, $0, 0xffffff sw $10, 268512724($0) addi $10, $0, 0xffffff sw $10, 268512728($0) addi $10, $0, 0xffffff sw $10, 268512732($0) addi $10, $0, 0xffffff sw $10, 268512736($0) addi $10, $0, 0xffffff sw $10, 268512740($0) addi $10, $0, 0xffffff sw $10, 268512744($0) addi $10, $0, 0xffffff sw $10, 268512748($0) addi $10, $0, 0xffffff sw $10, 268512752($0) addi $10, $0, 0xffffff sw $10, 268512756($0) addi $10, $0, 0xffffff sw $10, 268512760($0) addi $10, $0, 0x00d800 sw $10, 268512764($0) addi $10, $0, 0x00d800 sw $10, 268512768($0) addi $10, $0, 0xffffff sw $10, 268512772($0) addi $10, $0, 0xffffff sw $10, 268512776($0) addi $10, $0, 0xffffff sw $10, 268512780($0) addi $10, $0, 0xffffff sw $10, 268512784($0) addi $10, $0, 0xffffff sw $10, 268512788($0) addi $10, $0, 0xffffff sw $10, 268512792($0) addi $10, $0, 0xffffff sw $10, 268512796($0) addi $10, $0, 0xffffff sw $10, 268512800($0) addi $10, $0, 0xffffff sw $10, 268512804($0) addi $10, $0, 0xffffff sw $10, 268512808($0) addi $10, $0, 0xffffff sw $10, 268512812($0) addi $10, $0, 0xffffff sw $10, 268512816($0) addi $10, $0, 0xffffff sw $10, 268512820($0) addi $10, $0, 0xffffff sw $10, 268512824($0) addi $10, $0, 0xffffff sw $10, 268512828($0) addi $10, $0, 0xffffff sw $10, 268512832($0) addi $10, $0, 0xffffff sw $10, 268512836($0) addi $10, $0, 0xffffff sw $10, 268512840($0) addi $10, $0, 0xffffff sw $10, 268512844($0) addi $10, $0, 0xffffff sw $10, 268512848($0) addi $10, $0, 0xffffff sw $10, 268512852($0) addi $10, $0, 0xffffff sw $10, 268512856($0) addi $10, $0, 0xffffff sw $10, 268512860($0) addi $10, $0, 0xffffff sw $10, 268512864($0) addi $10, $0, 0xffffff sw $10, 268512868($0) addi $10, $0, 0xffffff sw $10, 268512872($0) addi $10, $0, 0xffffff sw $10, 268512876($0) addi $10, $0, 0xffffff sw $10, 268512880($0) addi $10, $0, 0xffffff sw $10, 268512884($0) addi $10, $0, 0xffffff sw $10, 268512888($0) addi $10, $0, 0xffffff sw $10, 268512892($0) addi $10, $0, 0xffffff sw $10, 268512896($0) addi $10, $0, 0xffffff sw $10, 268512900($0) addi $10, $0, 0xffffff sw $10, 268512904($0) addi $10, $0, 0xffffff sw $10, 268512908($0) addi $10, $0, 0xffffff sw $10, 268512912($0) addi $10, $0, 0xffffff sw $10, 268512916($0) addi $10, $0, 0xffffff sw $10, 268512920($0) addi $10, $0, 0xffffff sw $10, 268512924($0) addi $10, $0, 0xffffff sw $10, 268512928($0) addi $10, $0, 0xffffff sw $10, 268512932($0) addi $10, $0, 0xffffff sw $10, 268512936($0) addi $10, $0, 0xffffff sw $10, 268512940($0) addi $10, $0, 0xffffff sw $10, 268512944($0) addi $10, $0, 0xffffff sw $10, 268512948($0) addi $10, $0, 0xffffff sw $10, 268512952($0) addi $10, $0, 0xffffff sw $10, 268512956($0) addi $10, $0, 0xffffff sw $10, 268512960($0) addi $10, $0, 0xffffff sw $10, 268512964($0) addi $10, $0, 0xffffff sw $10, 268512968($0) addi $10, $0, 0xffffff sw $10, 268512972($0) addi $10, $0, 0xffffff sw $10, 268512976($0) addi $10, $0, 0xffffff sw $10, 268512980($0) addi $10, $0, 0xffffff sw $10, 268512984($0) addi $10, $0, 0xffffff sw $10, 268512988($0) addi $10, $0, 0xffffff sw $10, 268512992($0) addi $10, $0, 0xffffff sw $10, 268512996($0) addi $10, $0, 0xffffff sw $10, 268513000($0) addi $10, $0, 0xffffff sw $10, 268513004($0) addi $10, $0, 0xffffff sw $10, 268513008($0) addi $10, $0, 0xffffff sw $10, 268513012($0) addi $10, $0, 0xffffff sw $10, 268513016($0) addi $10, $0, 0x00d800 sw $10, 268513020($0) addi $10, $0, 0x00d800 sw $10, 268513024($0) addi $10, $0, 0xffffff sw $10, 268513028($0) addi $10, $0, 0xffffff sw $10, 268513032($0) addi $10, $0, 0xffffff sw $10, 268513036($0) addi $10, $0, 0xffffff sw $10, 268513040($0) addi $10, $0, 0xffffff sw $10, 268513044($0) addi $10, $0, 0xffffff sw $10, 268513048($0) addi $10, $0, 0xffffff sw $10, 268513052($0) addi $10, $0, 0xffffff sw $10, 268513056($0) addi $10, $0, 0xffffff sw $10, 268513060($0) addi $10, $0, 0xffffff sw $10, 268513064($0) addi $10, $0, 0xffffff sw $10, 268513068($0) addi $10, $0, 0xffffff sw $10, 268513072($0) addi $10, $0, 0xffffff sw $10, 268513076($0) addi $10, $0, 0xffffff sw $10, 268513080($0) addi $10, $0, 0xffffff sw $10, 268513084($0) addi $10, $0, 0xffffff sw $10, 268513088($0) addi $10, $0, 0xffffff sw $10, 268513092($0) addi $10, $0, 0xffffff sw $10, 268513096($0) addi $10, $0, 0xffffff sw $10, 268513100($0) addi $10, $0, 0xffffff sw $10, 268513104($0) addi $10, $0, 0xffffff sw $10, 268513108($0) addi $10, $0, 0xffffff sw $10, 268513112($0) addi $10, $0, 0xffffff sw $10, 268513116($0) addi $10, $0, 0xffffff sw $10, 268513120($0) addi $10, $0, 0xffffff sw $10, 268513124($0) addi $10, $0, 0xffffff sw $10, 268513128($0) addi $10, $0, 0xffffff sw $10, 268513132($0) addi $10, $0, 0xffffff sw $10, 268513136($0) addi $10, $0, 0xffffff sw $10, 268513140($0) addi $10, $0, 0xffffff sw $10, 268513144($0) addi $10, $0, 0xffffff sw $10, 268513148($0) addi $10, $0, 0xffffff sw $10, 268513152($0) addi $10, $0, 0xffffff sw $10, 268513156($0) addi $10, $0, 0xffffff sw $10, 268513160($0) addi $10, $0, 0xffffff sw $10, 268513164($0) addi $10, $0, 0xffffff sw $10, 268513168($0) addi $10, $0, 0xffffff sw $10, 268513172($0) addi $10, $0, 0xffffff sw $10, 268513176($0) addi $10, $0, 0xffffff sw $10, 268513180($0) addi $10, $0, 0xffffff sw $10, 268513184($0) addi $10, $0, 0xffffff sw $10, 268513188($0) addi $10, $0, 0xffffff sw $10, 268513192($0) addi $10, $0, 0xffffff sw $10, 268513196($0) addi $10, $0, 0xffffff sw $10, 268513200($0) addi $10, $0, 0xffffff sw $10, 268513204($0) addi $10, $0, 0xffffff sw $10, 268513208($0) addi $10, $0, 0xffffff sw $10, 268513212($0) addi $10, $0, 0xffffff sw $10, 268513216($0) addi $10, $0, 0xffffff sw $10, 268513220($0) addi $10, $0, 0xffffff sw $10, 268513224($0) addi $10, $0, 0xffffff sw $10, 268513228($0) addi $10, $0, 0xffffff sw $10, 268513232($0) addi $10, $0, 0xffffff sw $10, 268513236($0) addi $10, $0, 0xffffff sw $10, 268513240($0) addi $10, $0, 0xffffff sw $10, 268513244($0) addi $10, $0, 0xffffff sw $10, 268513248($0) addi $10, $0, 0xffffff sw $10, 268513252($0) addi $10, $0, 0xffffff sw $10, 268513256($0) addi $10, $0, 0xffffff sw $10, 268513260($0) addi $10, $0, 0xffffff sw $10, 268513264($0) addi $10, $0, 0xffffff sw $10, 268513268($0) addi $10, $0, 0xffffff sw $10, 268513272($0) addi $10, $0, 0x00d800 sw $10, 268513276($0) addi $10, $0, 0x00d800 sw $10, 268513280($0) addi $10, $0, 0xffffff sw $10, 268513284($0) addi $10, $0, 0xffffff sw $10, 268513288($0) addi $10, $0, 0xffffff sw $10, 268513292($0) addi $10, $0, 0xffffff sw $10, 268513296($0) addi $10, $0, 0xffffff sw $10, 268513300($0) addi $10, $0, 0xffffff sw $10, 268513304($0) addi $10, $0, 0xffffff sw $10, 268513308($0) addi $10, $0, 0xffffff sw $10, 268513312($0) addi $10, $0, 0xffffff sw $10, 268513316($0) addi $10, $0, 0xffffff sw $10, 268513320($0) addi $10, $0, 0xffffff sw $10, 268513324($0) addi $10, $0, 0xffffff sw $10, 268513328($0) addi $10, $0, 0xffffff sw $10, 268513332($0) addi $10, $0, 0xffffff sw $10, 268513336($0) addi $10, $0, 0xffffff sw $10, 268513340($0) addi $10, $0, 0xffffff sw $10, 268513344($0) addi $10, $0, 0xffffff sw $10, 268513348($0) addi $10, $0, 0xffffff sw $10, 268513352($0) addi $10, $0, 0xffffff sw $10, 268513356($0) addi $10, $0, 0xffffff sw $10, 268513360($0) addi $10, $0, 0xffffff sw $10, 268513364($0) addi $10, $0, 0xffffff sw $10, 268513368($0) addi $10, $0, 0xffffff sw $10, 268513372($0) addi $10, $0, 0xffffff sw $10, 268513376($0) addi $10, $0, 0xffffff sw $10, 268513380($0) addi $10, $0, 0xffffff sw $10, 268513384($0) addi $10, $0, 0xffffff sw $10, 268513388($0) addi $10, $0, 0xffffff sw $10, 268513392($0) addi $10, $0, 0xffffff sw $10, 268513396($0) addi $10, $0, 0xffffff sw $10, 268513400($0) addi $10, $0, 0xffffff sw $10, 268513404($0) addi $10, $0, 0xffffff sw $10, 268513408($0) addi $10, $0, 0xffffff sw $10, 268513412($0) addi $10, $0, 0xffffff sw $10, 268513416($0) addi $10, $0, 0xffffff sw $10, 268513420($0) addi $10, $0, 0xffffff sw $10, 268513424($0) addi $10, $0, 0xffffff sw $10, 268513428($0) addi $10, $0, 0xffffff sw $10, 268513432($0) addi $10, $0, 0xffffff sw $10, 268513436($0) addi $10, $0, 0xffffff sw $10, 268513440($0) addi $10, $0, 0xffffff sw $10, 268513444($0) addi $10, $0, 0xffffff sw $10, 268513448($0) addi $10, $0, 0xffffff sw $10, 268513452($0) addi $10, $0, 0xffffff sw $10, 268513456($0) addi $10, $0, 0xffffff sw $10, 268513460($0) addi $10, $0, 0xffffff sw $10, 268513464($0) addi $10, $0, 0xffffff sw $10, 268513468($0) addi $10, $0, 0xffffff sw $10, 268513472($0) addi $10, $0, 0xffffff sw $10, 268513476($0) addi $10, $0, 0xffffff sw $10, 268513480($0) addi $10, $0, 0xffffff sw $10, 268513484($0) addi $10, $0, 0xffffff sw $10, 268513488($0) addi $10, $0, 0xffffff sw $10, 268513492($0) addi $10, $0, 0xffffff sw $10, 268513496($0) addi $10, $0, 0xffffff sw $10, 268513500($0) addi $10, $0, 0xffffff sw $10, 268513504($0) addi $10, $0, 0xffffff sw $10, 268513508($0) addi $10, $0, 0xffffff sw $10, 268513512($0) addi $10, $0, 0xffffff sw $10, 268513516($0) addi $10, $0, 0xffffff sw $10, 268513520($0) addi $10, $0, 0xffffff sw $10, 268513524($0) addi $10, $0, 0xffffff sw $10, 268513528($0) addi $10, $0, 0x00d800 sw $10, 268513532($0) addi $10, $0, 0x00d800 sw $10, 268513536($0) addi $10, $0, 0xffffff sw $10, 268513540($0) addi $10, $0, 0xffffff sw $10, 268513544($0) addi $10, $0, 0xffffff sw $10, 268513548($0) addi $10, $0, 0xffffff sw $10, 268513552($0) addi $10, $0, 0xffffff sw $10, 268513556($0) addi $10, $0, 0xffffff sw $10, 268513560($0) addi $10, $0, 0xffffff sw $10, 268513564($0) addi $10, $0, 0xffffff sw $10, 268513568($0) addi $10, $0, 0xffffff sw $10, 268513572($0) addi $10, $0, 0xffffff sw $10, 268513576($0) addi $10, $0, 0xffffff sw $10, 268513580($0) addi $10, $0, 0xffffff sw $10, 268513584($0) addi $10, $0, 0xffffff sw $10, 268513588($0) addi $10, $0, 0xffffff sw $10, 268513592($0) addi $10, $0, 0xffffff sw $10, 268513596($0) addi $10, $0, 0xffffff sw $10, 268513600($0) addi $10, $0, 0xffffff sw $10, 268513604($0) addi $10, $0, 0xffffff sw $10, 268513608($0) addi $10, $0, 0xffffff sw $10, 268513612($0) addi $10, $0, 0xffffff sw $10, 268513616($0) addi $10, $0, 0xffffff sw $10, 268513620($0) addi $10, $0, 0xffffff sw $10, 268513624($0) addi $10, $0, 0xffffff sw $10, 268513628($0) addi $10, $0, 0xffffff sw $10, 268513632($0) addi $10, $0, 0xffffff sw $10, 268513636($0) addi $10, $0, 0xffffff sw $10, 268513640($0) addi $10, $0, 0xffffff sw $10, 268513644($0) addi $10, $0, 0xffffff sw $10, 268513648($0) addi $10, $0, 0xffffff sw $10, 268513652($0) addi $10, $0, 0xffffff sw $10, 268513656($0) addi $10, $0, 0xffffff sw $10, 268513660($0) addi $10, $0, 0xffffff sw $10, 268513664($0) addi $10, $0, 0xffffff sw $10, 268513668($0) addi $10, $0, 0xffffff sw $10, 268513672($0) addi $10, $0, 0xffffff sw $10, 268513676($0) addi $10, $0, 0xffffff sw $10, 268513680($0) addi $10, $0, 0xffffff sw $10, 268513684($0) addi $10, $0, 0xffffff sw $10, 268513688($0) addi $10, $0, 0xffffff sw $10, 268513692($0) addi $10, $0, 0xffffff sw $10, 268513696($0) addi $10, $0, 0xffffff sw $10, 268513700($0) addi $10, $0, 0xffffff sw $10, 268513704($0) addi $10, $0, 0xffffff sw $10, 268513708($0) addi $10, $0, 0xffffff sw $10, 268513712($0) addi $10, $0, 0xffffff sw $10, 268513716($0) addi $10, $0, 0xffffff sw $10, 268513720($0) addi $10, $0, 0xffffff sw $10, 268513724($0) addi $10, $0, 0xffffff sw $10, 268513728($0) addi $10, $0, 0xffffff sw $10, 268513732($0) addi $10, $0, 0xffffff sw $10, 268513736($0) addi $10, $0, 0xffffff sw $10, 268513740($0) addi $10, $0, 0xffffff sw $10, 268513744($0) addi $10, $0, 0xffffff sw $10, 268513748($0) addi $10, $0, 0xffffff sw $10, 268513752($0) addi $10, $0, 0xffffff sw $10, 268513756($0) addi $10, $0, 0xffffff sw $10, 268513760($0) addi $10, $0, 0xffffff sw $10, 268513764($0) addi $10, $0, 0xffffff sw $10, 268513768($0) addi $10, $0, 0xffffff sw $10, 268513772($0) addi $10, $0, 0xffffff sw $10, 268513776($0) addi $10, $0, 0xffffff sw $10, 268513780($0) addi $10, $0, 0xffffff sw $10, 268513784($0) addi $10, $0, 0x00d800 sw $10, 268513788($0) addi $10, $0, 0x00d800 sw $10, 268513792($0) addi $10, $0, 0xffffff sw $10, 268513796($0) addi $10, $0, 0xffffff sw $10, 268513800($0) addi $10, $0, 0xffffff sw $10, 268513804($0) addi $10, $0, 0xffffff sw $10, 268513808($0) addi $10, $0, 0xffffff sw $10, 268513812($0) addi $10, $0, 0xffffff sw $10, 268513816($0) addi $10, $0, 0xffffff sw $10, 268513820($0) addi $10, $0, 0xffffff sw $10, 268513824($0) addi $10, $0, 0xffffff sw $10, 268513828($0) addi $10, $0, 0xffffff sw $10, 268513832($0) addi $10, $0, 0xffffff sw $10, 268513836($0) addi $10, $0, 0xffffff sw $10, 268513840($0) addi $10, $0, 0xffffff sw $10, 268513844($0) addi $10, $0, 0xffffff sw $10, 268513848($0) addi $10, $0, 0xffffff sw $10, 268513852($0) addi $10, $0, 0xffffff sw $10, 268513856($0) addi $10, $0, 0xffffff sw $10, 268513860($0) addi $10, $0, 0xffffff sw $10, 268513864($0) addi $10, $0, 0xffffff sw $10, 268513868($0) addi $10, $0, 0xffffff sw $10, 268513872($0) addi $10, $0, 0xffffff sw $10, 268513876($0) addi $10, $0, 0xffffff sw $10, 268513880($0) addi $10, $0, 0xffffff sw $10, 268513884($0) addi $10, $0, 0xffffff sw $10, 268513888($0) addi $10, $0, 0xffffff sw $10, 268513892($0) addi $10, $0, 0xffffff sw $10, 268513896($0) addi $10, $0, 0xffffff sw $10, 268513900($0) addi $10, $0, 0xffffff sw $10, 268513904($0) addi $10, $0, 0xffffff sw $10, 268513908($0) addi $10, $0, 0xffffff sw $10, 268513912($0) addi $10, $0, 0xffffff sw $10, 268513916($0) addi $10, $0, 0xffffff sw $10, 268513920($0) addi $10, $0, 0xffffff sw $10, 268513924($0) addi $10, $0, 0xffffff sw $10, 268513928($0) addi $10, $0, 0xffffff sw $10, 268513932($0) addi $10, $0, 0xffffff sw $10, 268513936($0) addi $10, $0, 0xffffff sw $10, 268513940($0) addi $10, $0, 0xffffff sw $10, 268513944($0) addi $10, $0, 0xffffff sw $10, 268513948($0) addi $10, $0, 0xffffff sw $10, 268513952($0) addi $10, $0, 0xffffff sw $10, 268513956($0) addi $10, $0, 0xffffff sw $10, 268513960($0) addi $10, $0, 0xffffff sw $10, 268513964($0) addi $10, $0, 0xffffff sw $10, 268513968($0) addi $10, $0, 0xffffff sw $10, 268513972($0) addi $10, $0, 0xffffff sw $10, 268513976($0) addi $10, $0, 0xffffff sw $10, 268513980($0) addi $10, $0, 0xffffff sw $10, 268513984($0) addi $10, $0, 0xffffff sw $10, 268513988($0) addi $10, $0, 0xffffff sw $10, 268513992($0) addi $10, $0, 0xffffff sw $10, 268513996($0) addi $10, $0, 0xffffff sw $10, 268514000($0) addi $10, $0, 0xffffff sw $10, 268514004($0) addi $10, $0, 0xffffff sw $10, 268514008($0) addi $10, $0, 0xffffff sw $10, 268514012($0) addi $10, $0, 0xffffff sw $10, 268514016($0) addi $10, $0, 0xffffff sw $10, 268514020($0) addi $10, $0, 0xffffff sw $10, 268514024($0) addi $10, $0, 0xffffff sw $10, 268514028($0) addi $10, $0, 0xffffff sw $10, 268514032($0) addi $10, $0, 0xffffff sw $10, 268514036($0) addi $10, $0, 0xffffff sw $10, 268514040($0) addi $10, $0, 0x00d800 sw $10, 268514044($0) addi $10, $0, 0x00d800 sw $10, 268514048($0) addi $10, $0, 0xffffff sw $10, 268514052($0) addi $10, $0, 0xffffff sw $10, 268514056($0) addi $10, $0, 0xffffff sw $10, 268514060($0) addi $10, $0, 0xffffff sw $10, 268514064($0) addi $10, $0, 0xffffff sw $10, 268514068($0) addi $10, $0, 0xffffff sw $10, 268514072($0) addi $10, $0, 0x000000 sw $10, 268514076($0) addi $10, $0, 0x000000 sw $10, 268514080($0) addi $10, $0, 0x000000 sw $10, 268514084($0) addi $10, $0, 0x000000 sw $10, 268514088($0) addi $10, $0, 0x000000 sw $10, 268514092($0) addi $10, $0, 0xffffff sw $10, 268514096($0) addi $10, $0, 0xffffff sw $10, 268514100($0) addi $10, $0, 0xffffff sw $10, 268514104($0) addi $10, $0, 0xffffff sw $10, 268514108($0) addi $10, $0, 0xffffff sw $10, 268514112($0) addi $10, $0, 0xffffff sw $10, 268514116($0) addi $10, $0, 0x808080 sw $10, 268514120($0) addi $10, $0, 0x000000 sw $10, 268514124($0) addi $10, $0, 0xffffff sw $10, 268514128($0) addi $10, $0, 0xffffff sw $10, 268514132($0) addi $10, $0, 0x000000 sw $10, 268514136($0) addi $10, $0, 0xffffff sw $10, 268514140($0) addi $10, $0, 0xffffff sw $10, 268514144($0) addi $10, $0, 0xffffff sw $10, 268514148($0) addi $10, $0, 0xffffff sw $10, 268514152($0) addi $10, $0, 0xffffff sw $10, 268514156($0) addi $10, $0, 0xffffff sw $10, 268514160($0) addi $10, $0, 0x000000 sw $10, 268514164($0) addi $10, $0, 0x000000 sw $10, 268514168($0) addi $10, $0, 0x000000 sw $10, 268514172($0) addi $10, $0, 0xffffff sw $10, 268514176($0) addi $10, $0, 0xffffff sw $10, 268514180($0) addi $10, $0, 0xffffff sw $10, 268514184($0) addi $10, $0, 0xffffff sw $10, 268514188($0) addi $10, $0, 0xffffff sw $10, 268514192($0) addi $10, $0, 0xffffff sw $10, 268514196($0) addi $10, $0, 0xffffff sw $10, 268514200($0) addi $10, $0, 0xffffff sw $10, 268514204($0) addi $10, $0, 0x000000 sw $10, 268514208($0) addi $10, $0, 0x000000 sw $10, 268514212($0) addi $10, $0, 0x000000 sw $10, 268514216($0) addi $10, $0, 0x000000 sw $10, 268514220($0) addi $10, $0, 0xffffff sw $10, 268514224($0) addi $10, $0, 0xffffff sw $10, 268514228($0) addi $10, $0, 0xffffff sw $10, 268514232($0) addi $10, $0, 0xffffff sw $10, 268514236($0) addi $10, $0, 0xffffff sw $10, 268514240($0) addi $10, $0, 0xffffff sw $10, 268514244($0) addi $10, $0, 0xffffff sw $10, 268514248($0) addi $10, $0, 0x000000 sw $10, 268514252($0) addi $10, $0, 0x000000 sw $10, 268514256($0) addi $10, $0, 0x000000 sw $10, 268514260($0) addi $10, $0, 0x000000 sw $10, 268514264($0) addi $10, $0, 0xffffff sw $10, 268514268($0) addi $10, $0, 0xffffff sw $10, 268514272($0) addi $10, $0, 0xffffff sw $10, 268514276($0) addi $10, $0, 0xffffff sw $10, 268514280($0) addi $10, $0, 0xffffff sw $10, 268514284($0) addi $10, $0, 0xffffff sw $10, 268514288($0) addi $10, $0, 0xffffff sw $10, 268514292($0) addi $10, $0, 0xffffff sw $10, 268514296($0) addi $10, $0, 0x00d800 sw $10, 268514300($0) addi $10, $0, 0x00d800 sw $10, 268514304($0) addi $10, $0, 0xffffff sw $10, 268514308($0) addi $10, $0, 0xffffff sw $10, 268514312($0) addi $10, $0, 0xffffff sw $10, 268514316($0) addi $10, $0, 0xffffff sw $10, 268514320($0) addi $10, $0, 0xffffff sw $10, 268514324($0) addi $10, $0, 0xffffff sw $10, 268514328($0) addi $10, $0, 0xffffff sw $10, 268514332($0) addi $10, $0, 0xffffff sw $10, 268514336($0) addi $10, $0, 0x000000 sw $10, 268514340($0) addi $10, $0, 0xffffff sw $10, 268514344($0) addi $10, $0, 0xffffff sw $10, 268514348($0) addi $10, $0, 0xffffff sw $10, 268514352($0) addi $10, $0, 0xffffff sw $10, 268514356($0) addi $10, $0, 0xffffff sw $10, 268514360($0) addi $10, $0, 0xffffff sw $10, 268514364($0) addi $10, $0, 0xffffff sw $10, 268514368($0) addi $10, $0, 0xffffff sw $10, 268514372($0) addi $10, $0, 0x808080 sw $10, 268514376($0) addi $10, $0, 0x000000 sw $10, 268514380($0) addi $10, $0, 0xffffff sw $10, 268514384($0) addi $10, $0, 0xffffff sw $10, 268514388($0) addi $10, $0, 0x000000 sw $10, 268514392($0) addi $10, $0, 0xffffff sw $10, 268514396($0) addi $10, $0, 0xffffff sw $10, 268514400($0) addi $10, $0, 0xffffff sw $10, 268514404($0) addi $10, $0, 0xffffff sw $10, 268514408($0) addi $10, $0, 0xffffff sw $10, 268514412($0) addi $10, $0, 0xffffff sw $10, 268514416($0) addi $10, $0, 0x000000 sw $10, 268514420($0) addi $10, $0, 0xffffff sw $10, 268514424($0) addi $10, $0, 0x989898 sw $10, 268514428($0) addi $10, $0, 0x000000 sw $10, 268514432($0) addi $10, $0, 0xffffff sw $10, 268514436($0) addi $10, $0, 0xffffff sw $10, 268514440($0) addi $10, $0, 0xffffff sw $10, 268514444($0) addi $10, $0, 0xffffff sw $10, 268514448($0) addi $10, $0, 0xffffff sw $10, 268514452($0) addi $10, $0, 0xffffff sw $10, 268514456($0) addi $10, $0, 0xffffff sw $10, 268514460($0) addi $10, $0, 0x000000 sw $10, 268514464($0) addi $10, $0, 0xbfbfbf sw $10, 268514468($0) addi $10, $0, 0xffffff sw $10, 268514472($0) addi $10, $0, 0xffffff sw $10, 268514476($0) addi $10, $0, 0xffffff sw $10, 268514480($0) addi $10, $0, 0xffffff sw $10, 268514484($0) addi $10, $0, 0xffffff sw $10, 268514488($0) addi $10, $0, 0xffffff sw $10, 268514492($0) addi $10, $0, 0xffffff sw $10, 268514496($0) addi $10, $0, 0xffffff sw $10, 268514500($0) addi $10, $0, 0xffffff sw $10, 268514504($0) addi $10, $0, 0x000000 sw $10, 268514508($0) addi $10, $0, 0x404040 sw $10, 268514512($0) addi $10, $0, 0xffffff sw $10, 268514516($0) addi $10, $0, 0xffffff sw $10, 268514520($0) addi $10, $0, 0xffffff sw $10, 268514524($0) addi $10, $0, 0xffffff sw $10, 268514528($0) addi $10, $0, 0xffffff sw $10, 268514532($0) addi $10, $0, 0xffffff sw $10, 268514536($0) addi $10, $0, 0xffffff sw $10, 268514540($0) addi $10, $0, 0xffffff sw $10, 268514544($0) addi $10, $0, 0xffffff sw $10, 268514548($0) addi $10, $0, 0xffffff sw $10, 268514552($0) addi $10, $0, 0x00d800 sw $10, 268514556($0) addi $10, $0, 0x00d800 sw $10, 268514560($0) addi $10, $0, 0xffffff sw $10, 268514564($0) addi $10, $0, 0xffffff sw $10, 268514568($0) addi $10, $0, 0xffffff sw $10, 268514572($0) addi $10, $0, 0xffffff sw $10, 268514576($0) addi $10, $0, 0xffffff sw $10, 268514580($0) addi $10, $0, 0xffffff sw $10, 268514584($0) addi $10, $0, 0xffffff sw $10, 268514588($0) addi $10, $0, 0xffffff sw $10, 268514592($0) addi $10, $0, 0x000000 sw $10, 268514596($0) addi $10, $0, 0xffffff sw $10, 268514600($0) addi $10, $0, 0xffffff sw $10, 268514604($0) addi $10, $0, 0xffffff sw $10, 268514608($0) addi $10, $0, 0xffffff sw $10, 268514612($0) addi $10, $0, 0xffffff sw $10, 268514616($0) addi $10, $0, 0xffffff sw $10, 268514620($0) addi $10, $0, 0xffffff sw $10, 268514624($0) addi $10, $0, 0xffffff sw $10, 268514628($0) addi $10, $0, 0x808080 sw $10, 268514632($0) addi $10, $0, 0x000000 sw $10, 268514636($0) addi $10, $0, 0x000000 sw $10, 268514640($0) addi $10, $0, 0x000000 sw $10, 268514644($0) addi $10, $0, 0x000000 sw $10, 268514648($0) addi $10, $0, 0xffffff sw $10, 268514652($0) addi $10, $0, 0xffffff sw $10, 268514656($0) addi $10, $0, 0xffffff sw $10, 268514660($0) addi $10, $0, 0xffffff sw $10, 268514664($0) addi $10, $0, 0xffffff sw $10, 268514668($0) addi $10, $0, 0xffffff sw $10, 268514672($0) addi $10, $0, 0x000000 sw $10, 268514676($0) addi $10, $0, 0xffffff sw $10, 268514680($0) addi $10, $0, 0x282828 sw $10, 268514684($0) addi $10, $0, 0x000000 sw $10, 268514688($0) addi $10, $0, 0xffffff sw $10, 268514692($0) addi $10, $0, 0xffffff sw $10, 268514696($0) addi $10, $0, 0xffffff sw $10, 268514700($0) addi $10, $0, 0xffffff sw $10, 268514704($0) addi $10, $0, 0xffffff sw $10, 268514708($0) addi $10, $0, 0xffffff sw $10, 268514712($0) addi $10, $0, 0xffffff sw $10, 268514716($0) addi $10, $0, 0x000000 sw $10, 268514720($0) addi $10, $0, 0x000000 sw $10, 268514724($0) addi $10, $0, 0x000000 sw $10, 268514728($0) addi $10, $0, 0x000000 sw $10, 268514732($0) addi $10, $0, 0xffffff sw $10, 268514736($0) addi $10, $0, 0xffffff sw $10, 268514740($0) addi $10, $0, 0xffffff sw $10, 268514744($0) addi $10, $0, 0xffffff sw $10, 268514748($0) addi $10, $0, 0xffffff sw $10, 268514752($0) addi $10, $0, 0xffffff sw $10, 268514756($0) addi $10, $0, 0xffffff sw $10, 268514760($0) addi $10, $0, 0x000000 sw $10, 268514764($0) addi $10, $0, 0x000000 sw $10, 268514768($0) addi $10, $0, 0x000000 sw $10, 268514772($0) addi $10, $0, 0x000000 sw $10, 268514776($0) addi $10, $0, 0xffffff sw $10, 268514780($0) addi $10, $0, 0xffffff sw $10, 268514784($0) addi $10, $0, 0xffffff sw $10, 268514788($0) addi $10, $0, 0xffffff sw $10, 268514792($0) addi $10, $0, 0xffffff sw $10, 268514796($0) addi $10, $0, 0xffffff sw $10, 268514800($0) addi $10, $0, 0xffffff sw $10, 268514804($0) addi $10, $0, 0xffffff sw $10, 268514808($0) addi $10, $0, 0x00d800 sw $10, 268514812($0) addi $10, $0, 0x00d800 sw $10, 268514816($0) addi $10, $0, 0xffffff sw $10, 268514820($0) addi $10, $0, 0xffffff sw $10, 268514824($0) addi $10, $0, 0xffffff sw $10, 268514828($0) addi $10, $0, 0xffffff sw $10, 268514832($0) addi $10, $0, 0xffffff sw $10, 268514836($0) addi $10, $0, 0xffffff sw $10, 268514840($0) addi $10, $0, 0xffffff sw $10, 268514844($0) addi $10, $0, 0xffffff sw $10, 268514848($0) addi $10, $0, 0x000000 sw $10, 268514852($0) addi $10, $0, 0xffffff sw $10, 268514856($0) addi $10, $0, 0xffffff sw $10, 268514860($0) addi $10, $0, 0xffffff sw $10, 268514864($0) addi $10, $0, 0xffffff sw $10, 268514868($0) addi $10, $0, 0xffffff sw $10, 268514872($0) addi $10, $0, 0xffffff sw $10, 268514876($0) addi $10, $0, 0xffffff sw $10, 268514880($0) addi $10, $0, 0xffffff sw $10, 268514884($0) addi $10, $0, 0x808080 sw $10, 268514888($0) addi $10, $0, 0x000000 sw $10, 268514892($0) addi $10, $0, 0xdfdfdf sw $10, 268514896($0) addi $10, $0, 0xdfdfdf sw $10, 268514900($0) addi $10, $0, 0x000000 sw $10, 268514904($0) addi $10, $0, 0xffffff sw $10, 268514908($0) addi $10, $0, 0xffffff sw $10, 268514912($0) addi $10, $0, 0xffffff sw $10, 268514916($0) addi $10, $0, 0xffffff sw $10, 268514920($0) addi $10, $0, 0xffffff sw $10, 268514924($0) addi $10, $0, 0xffffff sw $10, 268514928($0) addi $10, $0, 0x000000 sw $10, 268514932($0) addi $10, $0, 0x000000 sw $10, 268514936($0) addi $10, $0, 0x000000 sw $10, 268514940($0) addi $10, $0, 0xffffff sw $10, 268514944($0) addi $10, $0, 0xffffff sw $10, 268514948($0) addi $10, $0, 0xffffff sw $10, 268514952($0) addi $10, $0, 0xffffff sw $10, 268514956($0) addi $10, $0, 0xffffff sw $10, 268514960($0) addi $10, $0, 0xffffff sw $10, 268514964($0) addi $10, $0, 0xffffff sw $10, 268514968($0) addi $10, $0, 0xffffff sw $10, 268514972($0) addi $10, $0, 0x000000 sw $10, 268514976($0) addi $10, $0, 0xbfbfbf sw $10, 268514980($0) addi $10, $0, 0xffffff sw $10, 268514984($0) addi $10, $0, 0xffffff sw $10, 268514988($0) addi $10, $0, 0xffffff sw $10, 268514992($0) addi $10, $0, 0xffffff sw $10, 268514996($0) addi $10, $0, 0xffffff sw $10, 268515000($0) addi $10, $0, 0xffffff sw $10, 268515004($0) addi $10, $0, 0xffffff sw $10, 268515008($0) addi $10, $0, 0xffffff sw $10, 268515012($0) addi $10, $0, 0xffffff sw $10, 268515016($0) addi $10, $0, 0x000000 sw $10, 268515020($0) addi $10, $0, 0x404040 sw $10, 268515024($0) addi $10, $0, 0xffffff sw $10, 268515028($0) addi $10, $0, 0xffffff sw $10, 268515032($0) addi $10, $0, 0xffffff sw $10, 268515036($0) addi $10, $0, 0xffffff sw $10, 268515040($0) addi $10, $0, 0xffffff sw $10, 268515044($0) addi $10, $0, 0xffffff sw $10, 268515048($0) addi $10, $0, 0xffffff sw $10, 268515052($0) addi $10, $0, 0xffffff sw $10, 268515056($0) addi $10, $0, 0xffffff sw $10, 268515060($0) addi $10, $0, 0xffffff sw $10, 268515064($0) addi $10, $0, 0x00d800 sw $10, 268515068($0) addi $10, $0, 0x00d800 sw $10, 268515072($0) addi $10, $0, 0xffffff sw $10, 268515076($0) addi $10, $0, 0xffffff sw $10, 268515080($0) addi $10, $0, 0xffffff sw $10, 268515084($0) addi $10, $0, 0xffffff sw $10, 268515088($0) addi $10, $0, 0xffffff sw $10, 268515092($0) addi $10, $0, 0xffffff sw $10, 268515096($0) addi $10, $0, 0xffffff sw $10, 268515100($0) addi $10, $0, 0xffffff sw $10, 268515104($0) addi $10, $0, 0x000000 sw $10, 268515108($0) addi $10, $0, 0xffffff sw $10, 268515112($0) addi $10, $0, 0xffffff sw $10, 268515116($0) addi $10, $0, 0xffffff sw $10, 268515120($0) addi $10, $0, 0xffffff sw $10, 268515124($0) addi $10, $0, 0xffffff sw $10, 268515128($0) addi $10, $0, 0xffffff sw $10, 268515132($0) addi $10, $0, 0xffffff sw $10, 268515136($0) addi $10, $0, 0xffffff sw $10, 268515140($0) addi $10, $0, 0x808080 sw $10, 268515144($0) addi $10, $0, 0x000000 sw $10, 268515148($0) addi $10, $0, 0xffffff sw $10, 268515152($0) addi $10, $0, 0xffffff sw $10, 268515156($0) addi $10, $0, 0x000000 sw $10, 268515160($0) addi $10, $0, 0xffffff sw $10, 268515164($0) addi $10, $0, 0xffffff sw $10, 268515168($0) addi $10, $0, 0xffffff sw $10, 268515172($0) addi $10, $0, 0xffffff sw $10, 268515176($0) addi $10, $0, 0xffffff sw $10, 268515180($0) addi $10, $0, 0xffffff sw $10, 268515184($0) addi $10, $0, 0x000000 sw $10, 268515188($0) addi $10, $0, 0xffffff sw $10, 268515192($0) addi $10, $0, 0x000000 sw $10, 268515196($0) addi $10, $0, 0x040404 sw $10, 268515200($0) addi $10, $0, 0xffffff sw $10, 268515204($0) addi $10, $0, 0xffffff sw $10, 268515208($0) addi $10, $0, 0xffffff sw $10, 268515212($0) addi $10, $0, 0xffffff sw $10, 268515216($0) addi $10, $0, 0xffffff sw $10, 268515220($0) addi $10, $0, 0xffffff sw $10, 268515224($0) addi $10, $0, 0xffffff sw $10, 268515228($0) addi $10, $0, 0x000000 sw $10, 268515232($0) addi $10, $0, 0xbfbfbf sw $10, 268515236($0) addi $10, $0, 0xffffff sw $10, 268515240($0) addi $10, $0, 0xffffff sw $10, 268515244($0) addi $10, $0, 0xffffff sw $10, 268515248($0) addi $10, $0, 0xffffff sw $10, 268515252($0) addi $10, $0, 0xffffff sw $10, 268515256($0) addi $10, $0, 0xffffff sw $10, 268515260($0) addi $10, $0, 0xffffff sw $10, 268515264($0) addi $10, $0, 0xffffff sw $10, 268515268($0) addi $10, $0, 0xffffff sw $10, 268515272($0) addi $10, $0, 0x000000 sw $10, 268515276($0) addi $10, $0, 0x404040 sw $10, 268515280($0) addi $10, $0, 0xffffff sw $10, 268515284($0) addi $10, $0, 0xffffff sw $10, 268515288($0) addi $10, $0, 0xffffff sw $10, 268515292($0) addi $10, $0, 0xffffff sw $10, 268515296($0) addi $10, $0, 0xffffff sw $10, 268515300($0) addi $10, $0, 0xffffff sw $10, 268515304($0) addi $10, $0, 0xffffff sw $10, 268515308($0) addi $10, $0, 0xffffff sw $10, 268515312($0) addi $10, $0, 0xffffff sw $10, 268515316($0) addi $10, $0, 0xffffff sw $10, 268515320($0) addi $10, $0, 0x00d800 sw $10, 268515324($0) addi $10, $0, 0x00d800 sw $10, 268515328($0) addi $10, $0, 0xffffff sw $10, 268515332($0) addi $10, $0, 0xffffff sw $10, 268515336($0) addi $10, $0, 0xffffff sw $10, 268515340($0) addi $10, $0, 0xffffff sw $10, 268515344($0) addi $10, $0, 0xffffff sw $10, 268515348($0) addi $10, $0, 0xffffff sw $10, 268515352($0) addi $10, $0, 0xffffff sw $10, 268515356($0) addi $10, $0, 0xffffff sw $10, 268515360($0) addi $10, $0, 0x000000 sw $10, 268515364($0) addi $10, $0, 0xffffff sw $10, 268515368($0) addi $10, $0, 0xffffff sw $10, 268515372($0) addi $10, $0, 0xffffff sw $10, 268515376($0) addi $10, $0, 0xffffff sw $10, 268515380($0) addi $10, $0, 0xffffff sw $10, 268515384($0) addi $10, $0, 0xffffff sw $10, 268515388($0) addi $10, $0, 0xffffff sw $10, 268515392($0) addi $10, $0, 0xffffff sw $10, 268515396($0) addi $10, $0, 0x808080 sw $10, 268515400($0) addi $10, $0, 0x000000 sw $10, 268515404($0) addi $10, $0, 0xffffff sw $10, 268515408($0) addi $10, $0, 0xffffff sw $10, 268515412($0) addi $10, $0, 0x000000 sw $10, 268515416($0) addi $10, $0, 0xffffff sw $10, 268515420($0) addi $10, $0, 0xffffff sw $10, 268515424($0) addi $10, $0, 0xffffff sw $10, 268515428($0) addi $10, $0, 0xffffff sw $10, 268515432($0) addi $10, $0, 0xffffff sw $10, 268515436($0) addi $10, $0, 0xffffff sw $10, 268515440($0) addi $10, $0, 0x000000 sw $10, 268515444($0) addi $10, $0, 0xffffff sw $10, 268515448($0) addi $10, $0, 0xffffff sw $10, 268515452($0) addi $10, $0, 0x000000 sw $10, 268515456($0) addi $10, $0, 0xffffff sw $10, 268515460($0) addi $10, $0, 0xffffff sw $10, 268515464($0) addi $10, $0, 0xffffff sw $10, 268515468($0) addi $10, $0, 0xffffff sw $10, 268515472($0) addi $10, $0, 0xffffff sw $10, 268515476($0) addi $10, $0, 0xffffff sw $10, 268515480($0) addi $10, $0, 0xffffff sw $10, 268515484($0) addi $10, $0, 0x000000 sw $10, 268515488($0) addi $10, $0, 0x000000 sw $10, 268515492($0) addi $10, $0, 0x000000 sw $10, 268515496($0) addi $10, $0, 0x000000 sw $10, 268515500($0) addi $10, $0, 0xffffff sw $10, 268515504($0) addi $10, $0, 0xffffff sw $10, 268515508($0) addi $10, $0, 0xffffff sw $10, 268515512($0) addi $10, $0, 0xffffff sw $10, 268515516($0) addi $10, $0, 0xffffff sw $10, 268515520($0) addi $10, $0, 0xffffff sw $10, 268515524($0) addi $10, $0, 0xffffff sw $10, 268515528($0) addi $10, $0, 0x000000 sw $10, 268515532($0) addi $10, $0, 0x000000 sw $10, 268515536($0) addi $10, $0, 0x000000 sw $10, 268515540($0) addi $10, $0, 0x000000 sw $10, 268515544($0) addi $10, $0, 0xffffff sw $10, 268515548($0) addi $10, $0, 0xffffff sw $10, 268515552($0) addi $10, $0, 0xffffff sw $10, 268515556($0) addi $10, $0, 0xffffff sw $10, 268515560($0) addi $10, $0, 0xffffff sw $10, 268515564($0) addi $10, $0, 0xffffff sw $10, 268515568($0) addi $10, $0, 0xffffff sw $10, 268515572($0) addi $10, $0, 0xffffff sw $10, 268515576($0) addi $10, $0, 0x00d800 sw $10, 268515580($0) addi $10, $0, 0x00d800 sw $10, 268515584($0) addi $10, $0, 0xffffff sw $10, 268515588($0) addi $10, $0, 0xffffff sw $10, 268515592($0) addi $10, $0, 0xffffff sw $10, 268515596($0) addi $10, $0, 0xffffff sw $10, 268515600($0) addi $10, $0, 0xffffff sw $10, 268515604($0) addi $10, $0, 0xffffff sw $10, 268515608($0) addi $10, $0, 0xffffff sw $10, 268515612($0) addi $10, $0, 0xffffff sw $10, 268515616($0) addi $10, $0, 0xffffff sw $10, 268515620($0) addi $10, $0, 0xffffff sw $10, 268515624($0) addi $10, $0, 0xffffff sw $10, 268515628($0) addi $10, $0, 0xffffff sw $10, 268515632($0) addi $10, $0, 0xffffff sw $10, 268515636($0) addi $10, $0, 0xffffff sw $10, 268515640($0) addi $10, $0, 0xffffff sw $10, 268515644($0) addi $10, $0, 0xffffff sw $10, 268515648($0) addi $10, $0, 0xffffff sw $10, 268515652($0) addi $10, $0, 0xffffff sw $10, 268515656($0) addi $10, $0, 0xffffff sw $10, 268515660($0) addi $10, $0, 0xffffff sw $10, 268515664($0) addi $10, $0, 0xffffff sw $10, 268515668($0) addi $10, $0, 0xffffff sw $10, 268515672($0) addi $10, $0, 0xffffff sw $10, 268515676($0) addi $10, $0, 0xffffff sw $10, 268515680($0) addi $10, $0, 0xffffff sw $10, 268515684($0) addi $10, $0, 0xffffff sw $10, 268515688($0) addi $10, $0, 0xffffff sw $10, 268515692($0) addi $10, $0, 0xffffff sw $10, 268515696($0) addi $10, $0, 0xffffff sw $10, 268515700($0) addi $10, $0, 0xffffff sw $10, 268515704($0) addi $10, $0, 0xffffff sw $10, 268515708($0) addi $10, $0, 0xffffff sw $10, 268515712($0) addi $10, $0, 0xffffff sw $10, 268515716($0) addi $10, $0, 0xffffff sw $10, 268515720($0) addi $10, $0, 0xffffff sw $10, 268515724($0) addi $10, $0, 0xffffff sw $10, 268515728($0) addi $10, $0, 0xffffff sw $10, 268515732($0) addi $10, $0, 0xffffff sw $10, 268515736($0) addi $10, $0, 0xffffff sw $10, 268515740($0) addi $10, $0, 0xffffff sw $10, 268515744($0) addi $10, $0, 0xffffff sw $10, 268515748($0) addi $10, $0, 0xffffff sw $10, 268515752($0) addi $10, $0, 0xffffff sw $10, 268515756($0) addi $10, $0, 0xffffff sw $10, 268515760($0) addi $10, $0, 0xffffff sw $10, 268515764($0) addi $10, $0, 0xffffff sw $10, 268515768($0) addi $10, $0, 0xffffff sw $10, 268515772($0) addi $10, $0, 0xffffff sw $10, 268515776($0) addi $10, $0, 0xffffff sw $10, 268515780($0) addi $10, $0, 0xffffff sw $10, 268515784($0) addi $10, $0, 0xffffff sw $10, 268515788($0) addi $10, $0, 0xffffff sw $10, 268515792($0) addi $10, $0, 0xffffff sw $10, 268515796($0) addi $10, $0, 0xffffff sw $10, 268515800($0) addi $10, $0, 0xffffff sw $10, 268515804($0) addi $10, $0, 0xffffff sw $10, 268515808($0) addi $10, $0, 0xffffff sw $10, 268515812($0) addi $10, $0, 0xffffff sw $10, 268515816($0) addi $10, $0, 0xffffff sw $10, 268515820($0) addi $10, $0, 0xffffff sw $10, 268515824($0) addi $10, $0, 0xffffff sw $10, 268515828($0) addi $10, $0, 0xffffff sw $10, 268515832($0) addi $10, $0, 0x00d800 sw $10, 268515836($0) addi $10, $0, 0x00d800 sw $10, 268515840($0) addi $10, $0, 0xffffff sw $10, 268515844($0) addi $10, $0, 0xffffff sw $10, 268515848($0) addi $10, $0, 0xffffff sw $10, 268515852($0) addi $10, $0, 0xffffff sw $10, 268515856($0) addi $10, $0, 0xffffff sw $10, 268515860($0) addi $10, $0, 0xffffff sw $10, 268515864($0) addi $10, $0, 0xffffff sw $10, 268515868($0) addi $10, $0, 0xffffff sw $10, 268515872($0) addi $10, $0, 0xffffff sw $10, 268515876($0) addi $10, $0, 0xffffff sw $10, 268515880($0) addi $10, $0, 0xffffff sw $10, 268515884($0) addi $10, $0, 0xffffff sw $10, 268515888($0) addi $10, $0, 0xffffff sw $10, 268515892($0) addi $10, $0, 0xffffff sw $10, 268515896($0) addi $10, $0, 0xffffff sw $10, 268515900($0) addi $10, $0, 0xffffff sw $10, 268515904($0) addi $10, $0, 0xffffff sw $10, 268515908($0) addi $10, $0, 0xffffff sw $10, 268515912($0) addi $10, $0, 0xffffff sw $10, 268515916($0) addi $10, $0, 0xffffff sw $10, 268515920($0) addi $10, $0, 0xffffff sw $10, 268515924($0) addi $10, $0, 0xffffff sw $10, 268515928($0) addi $10, $0, 0xffffff sw $10, 268515932($0) addi $10, $0, 0xffffff sw $10, 268515936($0) addi $10, $0, 0xffffff sw $10, 268515940($0) addi $10, $0, 0xffffff sw $10, 268515944($0) addi $10, $0, 0xffffff sw $10, 268515948($0) addi $10, $0, 0xffffff sw $10, 268515952($0) addi $10, $0, 0xffffff sw $10, 268515956($0) addi $10, $0, 0xffffff sw $10, 268515960($0) addi $10, $0, 0xffffff sw $10, 268515964($0) addi $10, $0, 0xffffff sw $10, 268515968($0) addi $10, $0, 0xffffff sw $10, 268515972($0) addi $10, $0, 0xffffff sw $10, 268515976($0) addi $10, $0, 0xffffff sw $10, 268515980($0) addi $10, $0, 0xffffff sw $10, 268515984($0) addi $10, $0, 0xffffff sw $10, 268515988($0) addi $10, $0, 0xffffff sw $10, 268515992($0) addi $10, $0, 0xffffff sw $10, 268515996($0) addi $10, $0, 0xffffff sw $10, 268516000($0) addi $10, $0, 0xffffff sw $10, 268516004($0) addi $10, $0, 0xffffff sw $10, 268516008($0) addi $10, $0, 0xffffff sw $10, 268516012($0) addi $10, $0, 0xffffff sw $10, 268516016($0) addi $10, $0, 0xffffff sw $10, 268516020($0) addi $10, $0, 0xffffff sw $10, 268516024($0) addi $10, $0, 0xffffff sw $10, 268516028($0) addi $10, $0, 0xffffff sw $10, 268516032($0) addi $10, $0, 0xffffff sw $10, 268516036($0) addi $10, $0, 0xffffff sw $10, 268516040($0) addi $10, $0, 0xffffff sw $10, 268516044($0) addi $10, $0, 0xffffff sw $10, 268516048($0) addi $10, $0, 0xffffff sw $10, 268516052($0) addi $10, $0, 0xffffff sw $10, 268516056($0) addi $10, $0, 0xffffff sw $10, 268516060($0) addi $10, $0, 0xffffff sw $10, 268516064($0) addi $10, $0, 0xffffff sw $10, 268516068($0) addi $10, $0, 0xffffff sw $10, 268516072($0) addi $10, $0, 0xffffff sw $10, 268516076($0) addi $10, $0, 0xffffff sw $10, 268516080($0) addi $10, $0, 0xffffff sw $10, 268516084($0) addi $10, $0, 0xffffff sw $10, 268516088($0) addi $10, $0, 0x00d800 sw $10, 268516092($0) addi $10, $0, 0x00d800 sw $10, 268516096($0) addi $10, $0, 0xffffff sw $10, 268516100($0) addi $10, $0, 0xffffff sw $10, 268516104($0) addi $10, $0, 0xffffff sw $10, 268516108($0) addi $10, $0, 0xffffff sw $10, 268516112($0) addi $10, $0, 0xffffff sw $10, 268516116($0) addi $10, $0, 0xffffff sw $10, 268516120($0) addi $10, $0, 0xffffff sw $10, 268516124($0) addi $10, $0, 0xffffff sw $10, 268516128($0) addi $10, $0, 0xffffff sw $10, 268516132($0) addi $10, $0, 0x000000 sw $10, 268516136($0) addi $10, $0, 0x000000 sw $10, 268516140($0) addi $10, $0, 0x000000 sw $10, 268516144($0) addi $10, $0, 0x000000 sw $10, 268516148($0) addi $10, $0, 0x000000 sw $10, 268516152($0) addi $10, $0, 0x000000 sw $10, 268516156($0) addi $10, $0, 0xffffff sw $10, 268516160($0) addi $10, $0, 0xffffff sw $10, 268516164($0) addi $10, $0, 0xffffff sw $10, 268516168($0) addi $10, $0, 0xffffff sw $10, 268516172($0) addi $10, $0, 0x000000 sw $10, 268516176($0) addi $10, $0, 0x000000 sw $10, 268516180($0) addi $10, $0, 0x000000 sw $10, 268516184($0) addi $10, $0, 0x000000 sw $10, 268516188($0) addi $10, $0, 0x000000 sw $10, 268516192($0) addi $10, $0, 0x000000 sw $10, 268516196($0) addi $10, $0, 0xffffff sw $10, 268516200($0) addi $10, $0, 0xffffff sw $10, 268516204($0) addi $10, $0, 0xffffff sw $10, 268516208($0) addi $10, $0, 0xffffff sw $10, 268516212($0) addi $10, $0, 0x000000 sw $10, 268516216($0) addi $10, $0, 0x000000 sw $10, 268516220($0) addi $10, $0, 0x000000 sw $10, 268516224($0) addi $10, $0, 0x000000 sw $10, 268516228($0) addi $10, $0, 0x000000 sw $10, 268516232($0) addi $10, $0, 0x000000 sw $10, 268516236($0) addi $10, $0, 0xffffff sw $10, 268516240($0) addi $10, $0, 0xffffff sw $10, 268516244($0) addi $10, $0, 0xffffff sw $10, 268516248($0) addi $10, $0, 0x000000 sw $10, 268516252($0) addi $10, $0, 0x000000 sw $10, 268516256($0) addi $10, $0, 0x000000 sw $10, 268516260($0) addi $10, $0, 0x000000 sw $10, 268516264($0) addi $10, $0, 0x000000 sw $10, 268516268($0) addi $10, $0, 0x000000 sw $10, 268516272($0) addi $10, $0, 0x808080 sw $10, 268516276($0) addi $10, $0, 0xffffff sw $10, 268516280($0) addi $10, $0, 0xffffff sw $10, 268516284($0) addi $10, $0, 0xffffff sw $10, 268516288($0) addi $10, $0, 0x000000 sw $10, 268516292($0) addi $10, $0, 0x000000 sw $10, 268516296($0) addi $10, $0, 0x000000 sw $10, 268516300($0) addi $10, $0, 0x000000 sw $10, 268516304($0) addi $10, $0, 0x000000 sw $10, 268516308($0) addi $10, $0, 0x000000 sw $10, 268516312($0) addi $10, $0, 0xffffff sw $10, 268516316($0) addi $10, $0, 0xffffff sw $10, 268516320($0) addi $10, $0, 0xffffff sw $10, 268516324($0) addi $10, $0, 0xffffff sw $10, 268516328($0) addi $10, $0, 0xffffff sw $10, 268516332($0) addi $10, $0, 0xffffff sw $10, 268516336($0) addi $10, $0, 0xffffff sw $10, 268516340($0) addi $10, $0, 0xffffff sw $10, 268516344($0) addi $10, $0, 0x00d800 sw $10, 268516348($0) addi $10, $0, 0x00d800 sw $10, 268516352($0) addi $10, $0, 0xffffff sw $10, 268516356($0) addi $10, $0, 0xffffff sw $10, 268516360($0) addi $10, $0, 0xffffff sw $10, 268516364($0) addi $10, $0, 0xffffff sw $10, 268516368($0) addi $10, $0, 0xffffff sw $10, 268516372($0) addi $10, $0, 0xffffff sw $10, 268516376($0) addi $10, $0, 0xffffff sw $10, 268516380($0) addi $10, $0, 0xffffff sw $10, 268516384($0) addi $10, $0, 0xffffff sw $10, 268516388($0) addi $10, $0, 0xffffff sw $10, 268516392($0) addi $10, $0, 0xffffff sw $10, 268516396($0) addi $10, $0, 0xffffff sw $10, 268516400($0) addi $10, $0, 0xffffff sw $10, 268516404($0) addi $10, $0, 0xffffff sw $10, 268516408($0) addi $10, $0, 0xffffff sw $10, 268516412($0) addi $10, $0, 0xffffff sw $10, 268516416($0) addi $10, $0, 0xffffff sw $10, 268516420($0) addi $10, $0, 0xffffff sw $10, 268516424($0) addi $10, $0, 0xffffff sw $10, 268516428($0) addi $10, $0, 0xffffff sw $10, 268516432($0) addi $10, $0, 0xffffff sw $10, 268516436($0) addi $10, $0, 0xffffff sw $10, 268516440($0) addi $10, $0, 0xffffff sw $10, 268516444($0) addi $10, $0, 0xffffff sw $10, 268516448($0) addi $10, $0, 0xffffff sw $10, 268516452($0) addi $10, $0, 0xffffff sw $10, 268516456($0) addi $10, $0, 0xffffff sw $10, 268516460($0) addi $10, $0, 0xffffff sw $10, 268516464($0) addi $10, $0, 0xffffff sw $10, 268516468($0) addi $10, $0, 0xffffff sw $10, 268516472($0) addi $10, $0, 0xffffff sw $10, 268516476($0) addi $10, $0, 0xffffff sw $10, 268516480($0) addi $10, $0, 0xffffff sw $10, 268516484($0) addi $10, $0, 0xffffff sw $10, 268516488($0) addi $10, $0, 0xffffff sw $10, 268516492($0) addi $10, $0, 0xffffff sw $10, 268516496($0) addi $10, $0, 0xffffff sw $10, 268516500($0) addi $10, $0, 0xffffff sw $10, 268516504($0) addi $10, $0, 0xffffff sw $10, 268516508($0) addi $10, $0, 0xffffff sw $10, 268516512($0) addi $10, $0, 0xffffff sw $10, 268516516($0) addi $10, $0, 0xffffff sw $10, 268516520($0) addi $10, $0, 0xffffff sw $10, 268516524($0) addi $10, $0, 0xffffff sw $10, 268516528($0) addi $10, $0, 0xffffff sw $10, 268516532($0) addi $10, $0, 0xffffff sw $10, 268516536($0) addi $10, $0, 0xffffff sw $10, 268516540($0) addi $10, $0, 0xffffff sw $10, 268516544($0) addi $10, $0, 0xffffff sw $10, 268516548($0) addi $10, $0, 0xffffff sw $10, 268516552($0) addi $10, $0, 0xffffff sw $10, 268516556($0) addi $10, $0, 0xffffff sw $10, 268516560($0) addi $10, $0, 0xffffff sw $10, 268516564($0) addi $10, $0, 0xffffff sw $10, 268516568($0) addi $10, $0, 0xffffff sw $10, 268516572($0) addi $10, $0, 0xffffff sw $10, 268516576($0) addi $10, $0, 0xffffff sw $10, 268516580($0) addi $10, $0, 0xffffff sw $10, 268516584($0) addi $10, $0, 0xffffff sw $10, 268516588($0) addi $10, $0, 0xffffff sw $10, 268516592($0) addi $10, $0, 0xffffff sw $10, 268516596($0) addi $10, $0, 0xffffff sw $10, 268516600($0) addi $10, $0, 0x00d800 sw $10, 268516604($0) addi $10, $0, 0x00d800 sw $10, 268516608($0) addi $10, $0, 0xffffff sw $10, 268516612($0) addi $10, $0, 0xffffff sw $10, 268516616($0) addi $10, $0, 0xffffff sw $10, 268516620($0) addi $10, $0, 0xffffff sw $10, 268516624($0) addi $10, $0, 0xffffff sw $10, 268516628($0) addi $10, $0, 0xffffff sw $10, 268516632($0) addi $10, $0, 0xffffff sw $10, 268516636($0) addi $10, $0, 0xffffff sw $10, 268516640($0) addi $10, $0, 0xffffff sw $10, 268516644($0) addi $10, $0, 0xffffff sw $10, 268516648($0) addi $10, $0, 0xffffff sw $10, 268516652($0) addi $10, $0, 0xffffff sw $10, 268516656($0) addi $10, $0, 0xffffff sw $10, 268516660($0) addi $10, $0, 0xffffff sw $10, 268516664($0) addi $10, $0, 0xffffff sw $10, 268516668($0) addi $10, $0, 0xffffff sw $10, 268516672($0) addi $10, $0, 0xffffff sw $10, 268516676($0) addi $10, $0, 0xffffff sw $10, 268516680($0) addi $10, $0, 0xffffff sw $10, 268516684($0) addi $10, $0, 0xffffff sw $10, 268516688($0) addi $10, $0, 0xffffff sw $10, 268516692($0) addi $10, $0, 0xffffff sw $10, 268516696($0) addi $10, $0, 0xffffff sw $10, 268516700($0) addi $10, $0, 0xffffff sw $10, 268516704($0) addi $10, $0, 0xffffff sw $10, 268516708($0) addi $10, $0, 0xffffff sw $10, 268516712($0) addi $10, $0, 0xffffff sw $10, 268516716($0) addi $10, $0, 0xffffff sw $10, 268516720($0) addi $10, $0, 0xffffff sw $10, 268516724($0) addi $10, $0, 0xffffff sw $10, 268516728($0) addi $10, $0, 0xffffff sw $10, 268516732($0) addi $10, $0, 0xffffff sw $10, 268516736($0) addi $10, $0, 0xffffff sw $10, 268516740($0) addi $10, $0, 0xffffff sw $10, 268516744($0) addi $10, $0, 0xffffff sw $10, 268516748($0) addi $10, $0, 0xffffff sw $10, 268516752($0) addi $10, $0, 0xffffff sw $10, 268516756($0) addi $10, $0, 0xffffff sw $10, 268516760($0) addi $10, $0, 0xffffff sw $10, 268516764($0) addi $10, $0, 0xffffff sw $10, 268516768($0) addi $10, $0, 0xffffff sw $10, 268516772($0) addi $10, $0, 0xffffff sw $10, 268516776($0) addi $10, $0, 0xffffff sw $10, 268516780($0) addi $10, $0, 0xffffff sw $10, 268516784($0) addi $10, $0, 0xffffff sw $10, 268516788($0) addi $10, $0, 0xffffff sw $10, 268516792($0) addi $10, $0, 0xffffff sw $10, 268516796($0) addi $10, $0, 0xffffff sw $10, 268516800($0) addi $10, $0, 0xffffff sw $10, 268516804($0) addi $10, $0, 0xffffff sw $10, 268516808($0) addi $10, $0, 0xffffff sw $10, 268516812($0) addi $10, $0, 0xffffff sw $10, 268516816($0) addi $10, $0, 0xffffff sw $10, 268516820($0) addi $10, $0, 0xffffff sw $10, 268516824($0) addi $10, $0, 0xffffff sw $10, 268516828($0) addi $10, $0, 0xffffff sw $10, 268516832($0) addi $10, $0, 0xffffff sw $10, 268516836($0) addi $10, $0, 0xffffff sw $10, 268516840($0) addi $10, $0, 0xffffff sw $10, 268516844($0) addi $10, $0, 0xffffff sw $10, 268516848($0) addi $10, $0, 0xffffff sw $10, 268516852($0) addi $10, $0, 0xffffff sw $10, 268516856($0) addi $10, $0, 0x00d800 sw $10, 268516860($0) addi $10, $0, 0x00d800 sw $10, 268516864($0) addi $10, $0, 0xffffff sw $10, 268516868($0) addi $10, $0, 0xffffff sw $10, 268516872($0) addi $10, $0, 0xffffff sw $10, 268516876($0) addi $10, $0, 0xffffff sw $10, 268516880($0) addi $10, $0, 0xffffff sw $10, 268516884($0) addi $10, $0, 0xffffff sw $10, 268516888($0) addi $10, $0, 0xffffff sw $10, 268516892($0) addi $10, $0, 0xffffff sw $10, 268516896($0) addi $10, $0, 0xffffff sw $10, 268516900($0) addi $10, $0, 0xffffff sw $10, 268516904($0) addi $10, $0, 0xffffff sw $10, 268516908($0) addi $10, $0, 0xffffff sw $10, 268516912($0) addi $10, $0, 0xffffff sw $10, 268516916($0) addi $10, $0, 0xffffff sw $10, 268516920($0) addi $10, $0, 0xffffff sw $10, 268516924($0) addi $10, $0, 0xffffff sw $10, 268516928($0) addi $10, $0, 0xffffff sw $10, 268516932($0) addi $10, $0, 0xffffff sw $10, 268516936($0) addi $10, $0, 0xffffff sw $10, 268516940($0) addi $10, $0, 0xffffff sw $10, 268516944($0) addi $10, $0, 0xffffff sw $10, 268516948($0) addi $10, $0, 0xffffff sw $10, 268516952($0) addi $10, $0, 0xffffff sw $10, 268516956($0) addi $10, $0, 0xffffff sw $10, 268516960($0) addi $10, $0, 0xffffff sw $10, 268516964($0) addi $10, $0, 0xffffff sw $10, 268516968($0) addi $10, $0, 0xffffff sw $10, 268516972($0) addi $10, $0, 0xffffff sw $10, 268516976($0) addi $10, $0, 0xffffff sw $10, 268516980($0) addi $10, $0, 0xffffff sw $10, 268516984($0) addi $10, $0, 0xffffff sw $10, 268516988($0) addi $10, $0, 0xffffff sw $10, 268516992($0) addi $10, $0, 0xffffff sw $10, 268516996($0) addi $10, $0, 0xffffff sw $10, 268517000($0) addi $10, $0, 0xffffff sw $10, 268517004($0) addi $10, $0, 0xffffff sw $10, 268517008($0) addi $10, $0, 0xffffff sw $10, 268517012($0) addi $10, $0, 0xffffff sw $10, 268517016($0) addi $10, $0, 0xffffff sw $10, 268517020($0) addi $10, $0, 0xffffff sw $10, 268517024($0) addi $10, $0, 0xffffff sw $10, 268517028($0) addi $10, $0, 0xffffff sw $10, 268517032($0) addi $10, $0, 0xffffff sw $10, 268517036($0) addi $10, $0, 0xffffff sw $10, 268517040($0) addi $10, $0, 0xffffff sw $10, 268517044($0) addi $10, $0, 0xffffff sw $10, 268517048($0) addi $10, $0, 0xffffff sw $10, 268517052($0) addi $10, $0, 0xffffff sw $10, 268517056($0) addi $10, $0, 0xffffff sw $10, 268517060($0) addi $10, $0, 0xffffff sw $10, 268517064($0) addi $10, $0, 0xffffff sw $10, 268517068($0) addi $10, $0, 0xffffff sw $10, 268517072($0) addi $10, $0, 0xffffff sw $10, 268517076($0) addi $10, $0, 0xffffff sw $10, 268517080($0) addi $10, $0, 0xffffff sw $10, 268517084($0) addi $10, $0, 0xffffff sw $10, 268517088($0) addi $10, $0, 0xffffff sw $10, 268517092($0) addi $10, $0, 0xffffff sw $10, 268517096($0) addi $10, $0, 0xffffff sw $10, 268517100($0) addi $10, $0, 0xffffff sw $10, 268517104($0) addi $10, $0, 0xffffff sw $10, 268517108($0) addi $10, $0, 0xffffff sw $10, 268517112($0) addi $10, $0, 0x00d800 sw $10, 268517116($0) addi $10, $0, 0x00d800 sw $10, 268517120($0) addi $10, $0, 0x00d800 sw $10, 268517124($0) addi $10, $0, 0x00d800 sw $10, 268517128($0) addi $10, $0, 0x00d800 sw $10, 268517132($0) addi $10, $0, 0x00d800 sw $10, 268517136($0) addi $10, $0, 0x00d800 sw $10, 268517140($0) addi $10, $0, 0x00d800 sw $10, 268517144($0) addi $10, $0, 0x00d800 sw $10, 268517148($0) addi $10, $0, 0x00d800 sw $10, 268517152($0) addi $10, $0, 0x00d800 sw $10, 268517156($0) addi $10, $0, 0x00d800 sw $10, 268517160($0) addi $10, $0, 0x00d800 sw $10, 268517164($0) addi $10, $0, 0x00d800 sw $10, 268517168($0) addi $10, $0, 0x00d800 sw $10, 268517172($0) addi $10, $0, 0x00d800 sw $10, 268517176($0) addi $10, $0, 0x00d800 sw $10, 268517180($0) addi $10, $0, 0x00d800 sw $10, 268517184($0) addi $10, $0, 0x00d800 sw $10, 268517188($0) addi $10, $0, 0x00d800 sw $10, 268517192($0) addi $10, $0, 0x00d800 sw $10, 268517196($0) addi $10, $0, 0x00d800 sw $10, 268517200($0) addi $10, $0, 0x00d800 sw $10, 268517204($0) addi $10, $0, 0x00d800 sw $10, 268517208($0) addi $10, $0, 0x00d800 sw $10, 268517212($0) addi $10, $0, 0x00d800 sw $10, 268517216($0) addi $10, $0, 0x00d800 sw $10, 268517220($0) addi $10, $0, 0x00d800 sw $10, 268517224($0) addi $10, $0, 0x00d800 sw $10, 268517228($0) addi $10, $0, 0x00d800 sw $10, 268517232($0) addi $10, $0, 0x00d800 sw $10, 268517236($0) addi $10, $0, 0x00d800 sw $10, 268517240($0) addi $10, $0, 0x00d800 sw $10, 268517244($0) addi $10, $0, 0x00d800 sw $10, 268517248($0) addi $10, $0, 0x00d800 sw $10, 268517252($0) addi $10, $0, 0x00d800 sw $10, 268517256($0) addi $10, $0, 0x00d800 sw $10, 268517260($0) addi $10, $0, 0x00d800 sw $10, 268517264($0) addi $10, $0, 0x00d800 sw $10, 268517268($0) addi $10, $0, 0x00d800 sw $10, 268517272($0) addi $10, $0, 0x00d800 sw $10, 268517276($0) addi $10, $0, 0x00d800 sw $10, 268517280($0) addi $10, $0, 0x00d800 sw $10, 268517284($0) addi $10, $0, 0x00d800 sw $10, 268517288($0) addi $10, $0, 0x00d800 sw $10, 268517292($0) addi $10, $0, 0x00d800 sw $10, 268517296($0) addi $10, $0, 0x00d800 sw $10, 268517300($0) addi $10, $0, 0x00d800 sw $10, 268517304($0) addi $10, $0, 0x00d800 sw $10, 268517308($0) addi $10, $0, 0x00d800 sw $10, 268517312($0) addi $10, $0, 0x00d800 sw $10, 268517316($0) addi $10, $0, 0x00d800 sw $10, 268517320($0) addi $10, $0, 0x00d800 sw $10, 268517324($0) addi $10, $0, 0x00d800 sw $10, 268517328($0) addi $10, $0, 0x00d800 sw $10, 268517332($0) addi $10, $0, 0x00d800 sw $10, 268517336($0) addi $10, $0, 0x00d800 sw $10, 268517340($0) addi $10, $0, 0x00d800 sw $10, 268517344($0) addi $10, $0, 0x00d800 sw $10, 268517348($0) addi $10, $0, 0x00d800 sw $10, 268517352($0) addi $10, $0, 0x00d800 sw $10, 268517356($0) addi $10, $0, 0x00d800 sw $10, 268517360($0) addi $10, $0, 0x00d800 sw $10, 268517364($0) addi $10, $0, 0x00d800 sw $10, 268517368($0) addi $10, $0, 0x00d800 sw $10, 268517372($0) jr $ra
// Copyright 2019 Uber Technologies, Inc. All Rights Reserved. // Modifications copyright Microsoft // // 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. // ============================================================================= #include "operation_manager.h" namespace horovod { namespace common { OperationManager::OperationManager(ParameterManager* param_manager, std::vector<std::shared_ptr<AllreduceOp>> allreduce_ops, std::vector<std::shared_ptr<AllgatherOp>> allgather_ops, std::vector<std::shared_ptr<BroadcastOp>> broadcast_ops, std::shared_ptr<JoinOp> join_op, std::vector<std::shared_ptr<AllreduceOp>> adasum_ops, std::shared_ptr<ErrorOp> error_op) : param_manager_(param_manager), allreduce_ops_(std::move(allreduce_ops)), allgather_ops_(std::move(allgather_ops)), broadcast_ops_(std::move(broadcast_ops)), join_op_(std::move(join_op)), adasum_ops_(std::move(adasum_ops)), error_op_(std::move(error_op)) {} Status OperationManager::ExecuteAllreduce(std::vector<TensorTableEntry>& entries, const Response& response) const { for (auto& op : allreduce_ops_) { if (op->Enabled(*param_manager_, entries, response)) { return op->Execute(entries, response); } } throw std::logic_error("No Allreduce operation enabled"); } Status OperationManager::ExecuteAllgather(std::vector<TensorTableEntry>& entries, const Response& response) const { for (auto& op : allgather_ops_) { if (op->Enabled(*param_manager_, entries, response)) { return op->Execute(entries, response); } } throw std::logic_error("No Allgather operation enabled"); } Status OperationManager::ExecuteBroadcast(std::vector<TensorTableEntry>& entries, const Response& response) const { for (auto& op : broadcast_ops_) { if (op->Enabled(*param_manager_, entries, response)) { return op->Execute(entries, response); } } throw std::logic_error("No Broadcast operation enabled"); } Status OperationManager::ExecuteJoin(std::vector<TensorTableEntry>& entries, const Response& response) const { return join_op_->Execute(entries, response); } Status OperationManager::ExecuteAdasum(std::vector<TensorTableEntry>& entries, const Response& response) const { for (auto& op : adasum_ops_) { if (op->Enabled(*param_manager_, entries, response)) { return op->Execute(entries, response); } } throw std::logic_error("No Adasum operation enabled"); } Status OperationManager::ExecuteError(std::vector<TensorTableEntry>& entries, const Response& response) const { return error_op_->Execute(entries, response); } Status OperationManager::ExecuteOperation(std::vector<TensorTableEntry>& entries, const Response& response) const { if (response.response_type() == Response::ALLREDUCE) { return ExecuteAllreduce(entries, response); } else if (response.response_type() == Response::ALLGATHER) { return ExecuteAllgather(entries, response); } else if (response.response_type() == Response::BROADCAST) { return ExecuteBroadcast(entries, response); } else if (response.response_type() == Response::JOIN) { return ExecuteJoin(entries, response); } else if (response.response_type() == Response::ADASUM) { return ExecuteAdasum(entries, response); } else if (response.response_type() == Response::ERROR) { return ExecuteError(entries, response); } else { throw std::logic_error("No operation found for response type provided"); } } } // namespace common } // namespace horovod
;=============================================================================== ; MODE - Display and/or modify device configuration ; ;=============================================================================== ; ; Author: Wayne Warthen (wwarthen@gmail.com) ;_______________________________________________________________________________ ; ; Usage: ; MODE /? ; MODE COM<n>: [<baud>[,<parity>[,<databits>[,<stopbits>]]]] [/P] ; ; <baud> is numerical baudrate ; <parity> is (N)one, (O)dd, (E)ven, (M)ark, or (S)pace ; <databits> is number of data bits, typically 7 or 8 ; <stopbits> is number of stop bits, typically 1 or 2 ; /P prompts user prior to setting new configuration ; ; Examples: ; MODE /? (display command usage) ; MODE (display configuration of all serial ports) ; MODE COM0: (display configuration of serial unit 0) ; MODE COM1: 9600,N,8,1 (set serial unit 1 configuration) ; ; Notes: ; - Parameters not provided will remain unchanged ; - Device must support specified configuration ;_______________________________________________________________________________ ; ; Change Log: ; 2017-08-16 [WBW] Initial release ; 2017-08-28 [WBW] Handle UNACPM ; 2018-07-24 [WBW] Fixed bug in getnum23 routine (credit Phil Summers) ;_______________________________________________________________________________ ; ; ToDo: ; 1) Implement flow control settings ;_______________________________________________________________________________ ; ;=============================================================================== ; Definitions ;=============================================================================== ; stksiz .equ $40 ; Working stack size ; restart .equ $0000 ; CP/M restart vector bdos .equ $0005 ; BDOS invocation vector ; ident .equ $FFFE ; loc of RomWBW HBIOS ident ptr ; rmj .equ 3 ; intended CBIOS version - major rmn .equ 1 ; intended CBIOS version - minor ; bf_cioinit .equ $04 ; HBIOS: CIOINIT function bf_cioquery .equ $05 ; HBIOS: CIOQUERY function bf_ciodevice .equ $06 ; HBIOS: CIODEVICE function bf_sysget .equ $F8 ; HBIOS: SYSGET function ; ;=============================================================================== ; Code Section ;=============================================================================== ; .org $100 ; ; setup stack (save old value) ld (stksav),sp ; save stack ld sp,stack ; set new stack ; ; initialization call init ; initialize jr nz,exit ; abort if init fails ; ; get the target device call getdev ; parse device/id from command line jr nz,exit ; abort on error ; ; process the configuration request call process ; parse device/id from command line jr nz,exit ; abort on error ; exit: ; clean up and return to command processor call crlf ; formatting ld sp,(stksav) ; restore stack jp restart ; return to CP/M via restart ret ; return to CP/M w/o restart ; ; Initialization ; init: ; locate start of cbios (function jump table) ld hl,(restart+1) ; load address of CP/M restart vector ld de,-3 ; adjustment for start of table add hl,de ; HL now has start of table ld (bioloc),hl ; save it ; ; check for UNA (UBIOS) ld a,($FFFD) ; fixed location of UNA API vector cp $C3 ; jp instruction? jr nz,initwbw ; if not, not UNA ld hl,($FFFE) ; get jp address ld a,(hl) ; get byte at target address cp $FD ; first byte of UNA push ix instruction jr nz,initwbw ; if not, not UNA inc hl ; point to next byte ld a,(hl) ; get next byte cp $E5 ; second byte of UNA push ix instruction jr nz,initwbw ; if not, not UNA ; ; UNA initialization ld hl,unamod ; point to UNA mode flag ld (hl),$FF ; set UNA mode flag ld a,$FF ; assume max units for UNA ld (comcnt),a ; ... and save it jr initx ; UNA init done ; initwbw: ; get location of config data and verify integrity ld hl,(ident) ; HL := adr or RomWBW HBIOS ident ld a,(hl) ; get first byte of RomWBW marker cp 'W' ; match? jp nz,errinv ; abort with invalid config block inc hl ; next byte (marker byte 2) ld a,(hl) ; load it cp ~'W' ; match? jp nz,errinv ; abort with invalid config block inc hl ; next byte (major/minor version) ld a,(hl) ; load it cp rmj << 4 | rmn ; match? jp nz,errver ; abort with invalid os version ; ; RomWBW initialization ld b,bf_sysget ; BIOS SYSGET function ld c,$00 ; CIOCNT subfunction rst 08 ; E := serial device unit count ld a,e ; count to A ld (comcnt),a ; save it ; initx ; initialization complete xor a ; signal success ret ; return ; ; Get target device specification (e.g., "COM1:") and save ; as devicetype/id. ; getdev: ; skip to start of first parm ld ix,$81 ; point to start of parm area (past len byte) call nonblank ; skip to next non-blank char jp z,prtcomall ; no parms, show all active ports ; getdev1: ; process options (if any) cp '/' ; option prefix? jr nz,getdev2 ; not an option, continue call option ; process option ret nz ; some options mean we are done (e.g., "/?") inc ix ; skip option character call nonblank ; skip whitespace jr getdev1 ; continue option checking ; getdev2: ; parse device mnemonic (e.g., "COM1") into tmpstr call getalpha ; extract alpha portion (e.g., "COM") call getnum ; extract numeric portion jp c,errunt ; handle overflow as invalid unit ld (unit),a ; save as unit number ; ; skip terminating ':' in device spec ld a,(ix) ; get current char cp ':' ; colon? jr nz,getdev3 ; done if no colon inc ix ; otherwise, skip the colon ; getdev3: call nonblank ; gobble any remaining whitespace xor a ; indicate success ret ; and return ; ; Process device ; process: ; match and branch according to device mnemonic ld hl,tmpstr ; point to start of extracted string ld de,strcom ; point to "COM" string call strcmp ; and compare jp z,comset ; handle COM port configuration jp errdev ; abort if bad device name ; ; Display or change serial port configuration ; comset: ; check for valid unit number ld hl,comcnt ; point to com device unit count ld a,(unit) ; get com device unit count cp (hl) ; compare to count (still in E) jr c,comset1 ; unit < count, continue jp errunt ; handle unit number error ; comset1: call ldcom ; load config for port ; ld a,(comatr) ; get attributes bit 7,a ; terminal? jp nz,prtcom ; terminal not configurable ; ld a,(ix) ; get current char cp 0 ; nothing more? jp z,prtcom ; no config parms, print current device config ; ; parse and update baudrate ld a,(ix) ; get current byte cp '0' ; check for jr c,comset1a ; ... valid digit cp '9'+1 ; ... else jump ahead jr nc,comset1a ; ... to handle empty ; call getnum32 ; get baud rate into DE:HL jp c,errcfg ; Handle overflow error ld c,75 ; Constant for baud rate encode call encode ; encode into C:4-0 jp nz,errcfg ; Error if encode fails ld a,(comcfg+1) ; Get high byte of config and %11100000 ; strip out old baud rate bits or c ; insert new baud rate bits ld (comcfg+1),a ; save it ; comset1a: ; parse and update parity call nonblank ; skip blanks jp z,comset9 ; end of parms cp ',' ; comma, as expected? jp nz,comset8 ; check for trailing options inc ix ; skip comma call nonblank ; skip possible blanks call ucase ; lookup parity value ld c,0 cp 'N' jr z,comset2 ld c,1 cp 'O' jr z,comset2 ld c,3 cp 'E' jr z,comset2 ld c,5 cp 'M' jr z,comset2 ld c,7 cp 'S' jr z,comset2 jr comset3 ; unexpected parity char, possibly empty ; comset2: ; update parity value ld a,c ; new parity value to A rlca ; rotate to bits 5-3 rlca ; rlca ; ld c,a ; and back to C ld a,(comcfg) ; parity is in comcfg:5-3 and %11000111 ; strip old value or c ; apply new value ld (comcfg),a ; and save it inc ix ; bump past parity char ; comset3: ; parse & update data bits call nonblank ; skip blanks jr z,comset9 ; end of parms cp ',' ; comma, as expected? jr nz,comset8 ; check for trailing options inc ix ; skip comma call nonblank ; skip possible blanks sub '5' ; normalize value cp 4 ; value should now be 0-3 jr nc,comset4 ; unexpected, possibly empty ld c,a ; move new value to C ld a,(comcfg) ; data bits is in comcfg:1-0 and %11111100 ; strip old value or c ; apply new value ld (comcfg),a ; and save it inc ix ; bump past data bits char ; comset4: ; parse & update stop bits call nonblank ; skip blanks jr z,comset9 ; end of parms cp ',' ; comma, as expected? jr nz,comset8 ; check for trailing options inc ix ; skip comma call nonblank ; skip possible blanks sub '1' ; normalize value cp 2 ; value should now be 0-1 jr nc,comset8 ; unexpected, possibly empty rlca ; rotate to bit 2 rlca ld c,a ; move new value to C ld a,(comcfg) ; stop bit is in comcfg:2 and %11111011 ; strip old value or c ; apply new value ld (comcfg),a ; and save it inc ix ; bump past stop bits char ; comset8: ; trailing options call nonblank ; skip blanks jr z,comset9 ; end of parms cp '/' ; option introducer? jp nz,errprm ; parameter error inc ix ; bump part '/' ld a,(ix) ; get character call ucase ; make upper case cp 'P' ; only valid option jp nz,errprm ; parameter error ld a,$FF ; set prompt value on ld (pflag),a ; save it inc ix ; bump past character jr comset8 ; process more parms ; comset9: ; display new config ld de,(comcfg) ; get new config call prtcom ; print it ld a,(pflag) ; get prompt flag or a ; set flags jr z,comset9b ; bypass if not requested call crlf2 ; spacing ld de,indent ; indent call prtstr ; do it ld de,msgpmt ; point to prmopt message call prtstr ; print it ; ld b,64 comset9a: xor a call prtchr djnz comset9a ; comset9b: ; check for UNA ld a,(unamod) ; get UNA flag or a ; set flags jr nz,comsetu ; go to UNA variant ; ; implement new config ld de,(comcfg) ; get new config value to DE ld b,bf_cioinit ; BIOS serial init ld a,(unit) ; get serial device unit ld c,a ; ... into C rst 08 ; call HBIOS jp nz,errcfg ; handle error jr comsetx ; common exit ; comsetu: ; implement new config under UNA ld de,(comcfg) ; get new config value to DE ld c,$10 ; UNA INIT function ld a,(unit) ; get serial device unit ld b,a ; ... into B rst 08 ; call HBIOS jp nz,errcfg ; handle error jr comsetx ; common exit ; comsetx: ld a,(pflag) ; get prompt flag or a ; set flags jr z,comsetx2 ; bypass if not requested comsetx1: ld c,$01 ; console read call bdos ; do it cp $0D ; CR? jr nz,comsetx1 ; loop as needed ; comsetx2: xor a ret ; ; Print configuration of all serial ports ; prtcomall: ld a,(comcnt) ; get com device unit count ld b,a ; init B as loop counter ld c,0 ; init C as unit index ; prtcomall1: push bc ; save loop control ; ; get port info ld a,c ; put unit number ld (unit),a ; ... into unit call ldcom ; get config jr z,prtcomall2 ; no error, continue pop bc ; unwind stack ret ; and return with NZ ; prtcomall2: ; print config for port call prtcom ; print line for this port ; ; loop as needed pop bc ; restore loop control inc c ; next unit index djnz prtcomall1 ; loop till done ; or $FF ; indicate nothing more to do ret ; finished ; ; Print configuration of serial port ; prtcom: ; print leader (e.g., "COM0: ") call crlf ld de,indent call prtstr ld de,strcom call prtstr ld a,(unit) call prtdecb ld a,':' call prtchr ld a,' ' call prtchr ; ld a,(comatr) ; get attribute byte bit 7,a ; 0=RS232, 1=terminal jr z,prtcom1 ; handle serial port configuration ; ; this is a terminal, just say so ld de,strterm ; point to string call prtstr ; print it ret ; and return ; prtcom1: ld de,(comcfg) ; load config to DE ; ; print baud rate push de ; save it ld a,d ; baud rate is in D and $1F ; ... bits 4-0 ld l,a ; move to L ld h,0 ; setup H for decode routine ld de,75 ; set DE to baud rate decode constant call decode ; decode baud rate, DE:HL := baud rate ld bc,bcdtmp ; point to temp bcd buffer call bin2bcd ; convert baud to BCD call prtbcd ; and print in decimal pop de ; restore line characteristics ; ; print parity ld a,',' ; A := comma call prtchr ; ... print it ld a,e ; E has parity config rrca ; isolate bits 5-3 rrca ; ... rrca ; ... and $07 ; ... ld hl,parmap ; HL := start of parity char table call addhl ; index into table ld a,(hl) ; get resulting parity char call prtchr ; and print ; ; print data bits ld a,',' ; A := comma call prtchr ; ... print it ld a,e ; E has data bits config and $03 ; isloate bits 1-0 add A,'5' ; convert to printable char call prtchr ; and print it ; ; print stop bits ld a,',' ; A := comma call prtchr ; ... print it ld a,e ; E has stop bits config rrca ; isolate bit 2 rrca ; ... and $01 ; ... add A,'1' ; convert to printable char call prtchr ; and print it ; ret ; ; Load serial device info for specific unit ; ldcom: ld a,(unamod) ; get UNA flag or a ; set flags jr nz,ldcomu ; go to UNA variant ; ; get device type info ld a,(unit) ; get unit ld b,bf_ciodevice ; BIOS device call ld c,a ; ... and put in C rst 08 ; call HBIOS, C := attributes ret nz ; return on error ld a,c ; attributes to A ld (comatr),a ; save it ; ; get serial port config ld b,bf_cioquery ; BIOS serial device query ld a,(unit) ; get device unit num ld c,a ; ... and put in C rst 08 ; call H/UBIOS, DE := line characteristics ret nz ; abort on error ld (comcfg),de ; save config ; xor a ; success ret ; ldcomu: ; UNA variant xor a ; assume attribtues zero ld (comatr),a ; save it ; get device info ld a,(unit) ; get unit ld b,a ; put unit in B ld c,$18 ; UNA Get line/driver info func rst 08 ; call H/UBIOS, DE := line characteristics ld a,c or a jr z,ldcomu1 cp $43 ; $43 is OK for now (tell John about this) jr z,ldcomu1 ret ; return w/ NZ indicating error ; ldcomu1: ld (comcfg),de ; save config ; xor a ; success ret ; ; Handle special options ; option: ; inc ix ; next char ld a,(ix) ; get it cp '?' ; is it a '?' as expected? jp z,usage ; yes, display usage ; cp 'L' ; is it a 'L', display device list? ; jp z,devlist ; yes, display device list jp errprm ; anything else is an error ; ; Display usage ; usage: ; call crlf ; formatting ld de,msgban1 ; point to version message part 1 call prtstr ; print it ld a,(unamod) ; get UNA flag or a ; set flags ld de,msghb ; point to HBIOS mode message call z,prtstr ; if not UNA, say so ld de,msgub ; point to UBIOS mode message call nz,prtstr ; if UNA, say so call crlf ; formatting ld de,msgban2 ; point to version message part 2 call prtstr ; print it call crlf2 ; blank line ld de,msguse ; point to usage message call prtstr ; print it or $FF ; signal no action performed ret ; and return ; ; Print character in A without destroying any registers ; prtchr: push bc ; save registers push de push hl ld e,a ; character to print in E ld c,$02 ; BDOS function to output a character call bdos ; do it pop hl ; restore registers pop de pop bc ret ; prtdot: ; ; shortcut to print a dot preserving all regs push af ; save af ld a,'.' ; load dot char call prtchr ; print it pop af ; restore af ret ; done ; ; Print a zero terminated string at (DE) without destroying any registers ; prtstr: push de ; prtstr1: ld a,(de) ; get next char or a jr z,prtstr2 call prtchr inc de jr prtstr1 ; prtstr2: pop de ; restore registers ret ; ; Print the value in A in hex without destroying any registers ; prthex: push af ; save AF push de ; save DE call hexascii ; convert value in A to hex chars in DE ld a,d ; get the high order hex char call prtchr ; print it ld a,e ; get the low order hex char call prtchr ; print it pop de ; restore DE pop af ; restore AF ret ; done ; ; print the hex word value in bc ; prthexword: push af ld a,b call prthex ld a,c call prthex pop af ret ; ; print the hex dword value in de:hl ; prthex32: push bc push de pop bc call prthexword push hl pop bc call prthexword pop bc ret ; ; Convert binary value in A to ascii hex characters in DE ; hexascii: ld d,a ; save A in D call hexconv ; convert low nibble of A to hex ld e,a ; save it in E ld a,d ; get original value back rlca ; rotate high order nibble to low bits rlca rlca rlca call hexconv ; convert nibble ld d,a ; save it in D ret ; done ; ; Convert low nibble of A to ascii hex ; hexconv: and $0F ; low nibble only add a,$90 daa adc a,$40 daa ret ; ; Print value of A or HL in decimal with leading zero suppression ; Use prtdecb for A or prtdecw for HL ; prtdecb: push hl ld h,0 ld l,a call prtdecw ; print it pop hl ret ; prtdecw: push af push bc push de push hl call prtdec0 pop hl pop de pop bc pop af ret ; prtdec0: ld e,'0' ld bc,-10000 call prtdec1 ld bc,-1000 call prtdec1 ld bc,-100 call prtdec1 ld c,-10 call prtdec1 ld e,0 ld c,-1 prtdec1: ld a,'0' - 1 prtdec2: inc a add hl,bc jr c,prtdec2 sbc hl,bc cp e ret z ld e,0 call prtchr ret ; ; Start a new line ; crlf2: call crlf ; two of them crlf: push af ; preserve AF ld a,13 ; <CR> call prtchr ; print it ld a,10 ; <LF> call prtchr ; print it pop af ; restore AF ret ; ; Get the next non-blank character from (HL). ; nonblank: ld a,(ix) ; load next character or a ; string ends with a null ret z ; if null, return pointing to null cp ' ' ; check for blank ret nz ; return if not blank inc ix ; if blank, increment character pointer jr nonblank ; and loop ; ; Get alpha chars and save in tmpstr ; Length of string returned in A ; getalpha: ; ld hl,tmpstr ; location to save chars ld b,8 ; length counter (tmpstr max chars) ld c,0 ; init character counter ; getalpha1: ld a,(ix) ; get active char call ucase ; lower case -> uppper case, if needed cp 'A' ; check for start of alpha range jr c,getalpha2 ; not alpha, get out cp 'Z' + 1 ; check for end of alpha range jr nc,getalpha2 ; not alpha, get out ; handle alpha char ld (hl),a ; save it inc c ; bump char count inc hl ; inc string pointer inc ix ; increment buffer ptr djnz getalpha1 ; if space, loop for more chars ; getalpha2: ; non-alpha, clean up and return ld (hl),0 ; terminate string ld a,c ; string length to A or a ; set flags ret ; and return ; ; Get numeric chars and convert to number returned in A ; Carry flag set on overflow ; getnum: ld c,0 ; C is working register getnum1: ld a,(ix) ; get the active char cp '0' ; compare to ascii '0' jr c,getnum2 ; abort if below cp '9' + 1 ; compare to ascii '9' jr nc,getnum2 ; abort if above ; ; valid digit, add new digit to C ld a,c ; get working value to A rlca ; multiply by 10 ret c ; overflow, return with carry set rlca ; ... ret c ; overflow, return with carry set add a,c ; ... ret c ; overflow, return with carry set rlca ; ... ret c ; overflow, return with carry set ld c,a ; back to C ld a,(ix) ; get new digit sub '0' ; make binary add a,c ; add in working value ret c ; overflow, return with carry set ld c,a ; back to C ; inc ix ; bump to next char jr getnum1 ; loop ; getnum2: ; return result ld a,c ; return result in A or a ; with flags set, CF is cleared ret ; ; Get numeric chars and convert to 32-bit number returned in DE:HL ; Carry flag set on overflow ; getnum32: ld de,0 ; Initialize DE:HL ld hl,0 ; ... to zero getnum32a: ld a,(ix) ; get the active char cp '0' ; compare to ascii '0' jr c,getnum32c ; abort if below cp '9' + 1 ; compare to ascii '9' jr nc,getnum32c ; abort if above ; ; valid digit, multiply DE:HL by 10 ; X * 10 = (((x * 2 * 2) + x)) * 2 push de push hl ; call getnum32e ; DE:HL *= 2 jr c,getnum32d ; if overflow, ret w/ CF & stack pop ; call getnum32e ; DE:HL *= 2 jr c,getnum32d ; if overflow, ret w/ CF & stack pop ; pop bc ; DE:HL += X add hl,bc ex de,hl pop bc adc hl,bc ex de,hl ret c ; if overflow, ret w/ CF ; call getnum32e ; DE:HL *= 2 ret c ; if overflow, ret w/ CF ; ; now add in new digit ld a,(ix) ; get the active char sub '0' ; make it binary add a,l ; add to L, CF updated ld l,a ; back to L jr nc,getnum32b ; if no carry, done inc h ; otherwise, bump H jr nz,getnum32b ; if no overflow, done inc e ; otherwise, bump E jr nz,getnum32b ; if no overflow, done inc d ; otherwise, bump D jr nz,getnum32b ; if no overflow, done scf ; set carry flag to indicate overflow ret ; and return ; getnum32b: inc ix ; bump to next char jr getnum32a ; loop ; getnum32c: ; successful completion xor a ; clear flags ret ; and return ; getnum32d: ; special overflow exit with stack fixup pop hl ; burn 2 pop hl ; ... stack entries ret ; and return ; getnum32e: ; DE:HL := DE:HL * 2 sla l rl h rl e rl d ret ; ; Compare null terminated strings at HL & DE ; If equal return with Z set, else NZ ; strcmp: ld a,(de) ; get current source char cp (hl) ; compare to current dest char ret nz ; compare failed, return with NZ or a ; set flags ret z ; end of string, match, return with Z set inc de ; point to next char in source inc hl ; point to next char in dest jr strcmp ; loop till done ; ; Convert character in A to uppercase ; ucase: cp 'a' ; if below 'a' ret c ; ... do nothing and return cp 'z' + 1 ; if above 'z' ret nc ; ... do nothing and return res 5,a ; clear bit 5 to make lower case -> upper case ret ; and return ; ; Add the value in A to HL (HL := HL + A) ; addhl: add a,l ; A := A + L ld l,a ; Put result back in L ret nc ; if no carry, we are done inc h ; if carry, increment H ret ; and return ; ; Integer divide DE:HL by C ; result in DE:HL, remainder in A ; clobbers F, B ; div32x8: xor a ld b,32 div32x8a: add hl,hl rl e rl d rla cp c jr c,div32x8b sub c inc l div32x8b: djnz div32x8a ret ; ; Jump indirect to address in HL ; jphl: jp (hl) ; ; Errors ; erruse: ; command usage error (syntax) ld de,msguse jr err ; errprm: ; command parameter error (syntax) ld de,msgprm jr err ; errinv: ; invalid HBIOS, signature not found ld de,msginv jr err ; errver: ; unsupported HBIOS version ld de,msgver jr err ; errdev: ; invalid device name ld de,msgdev jr err ; errnum: ; invalid number parsed, overflow ld de,msgnum jr err ; errunt: ; Invalid device unit specified ld de,msgunt jr err ; errcfg: ; Invalid device configuration specified ld de,msgcfg jr err ; err: ; print error string and return error signal call crlf2 ; print newline ; err1: ; without the leading crlf call prtstr ; print error string ; err2: ; without the string ; call crlf ; print newline or $FF ; signal error ret ; done ; ;=============================================================================== ; Utility modules ;=============================================================================== ; #include "Encode.asm" #include "Decode.asm" #include "bcd.asm" ; ;=============================================================================== ; Storage Section ;=============================================================================== ; ; bioloc .dw 0 ; CBIOS starting address unit .db 0 ; source unit ; unamod .db 0 ; $FF indicates UNA UBIOS active ; tmpstr .fill 9,0 ; temporary string of up to 8 chars, zero term bcdtmp .fill 5,0 ; temporary bcd number storage ; comcnt .db 0 ; count of com ports comatr .db 0 ; com port attributes comcfg .dw 0 ; com port configuration ; parmap .db "NONENMNS" ; parity character lookup table ; pflag .db 0 ; $FF indicates prompt option set ; strcom .db "COM",0 ; serial device name string strterm .db "VDU",0 ; terminal device string ; stksav .dw 0 ; stack pointer saved at start .fill stksiz,0 ; stack stack .equ $ ; stack top ; ; Messages ; indent .db " ",0 msgban1 .db "MODE v1.2, 24-Jul-2018",0 msghb .db " [HBIOS]",0 msgub .db " [UBIOS]",0 msgban2 .db "Copyright (C) 2017, Wayne Warthen, GNU GPL v3",0 msguse .db "Usage: MODE COM<n>: [<baud>[,<parity>[,<databits>[,<stopbits>]]]] [/P]",13,10 .db " ex. MODE /? (display version and usage)",13,10 .db " MODE (display config of all serial ports)",13,10 .db " MODE COM0: (display serial unit 0 config)",13,10 .db " MODE COM1: 9600,N,8,1 (set serial unit 1 config)",0 msgprm .db "Parameter error (MODE /? for usage)",0 msginv .db "Invalid BIOS (signature missing)",0 msgver .db "Unexpected HBIOS version",0 msgdev .db "Invalid device name",0 msgnum .db "Unit or slice number invalid",0 msgunt .db "Invalid device unit number specified",0 msgcfg .db "Invalid device configuration specified",0 msgpmt .db "Prepare line then press <return>",0 ; .end
; MASM math definitions for libcgc ; ; Original license: ; Copyright (c) 2014 Jason L. Wright (jason@thought.net) ; 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. ; ; 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. ; ; ; # basic assembly math routines for DARPA Cyber Grand Challenge .MODEL FLAT, C .CODE _ENTER MACRO base PUBLIC base& PUBLIC base&f base&l PROC ENDM _END MACRO base base& ENDP base&f ENDP base&l ENDP ENDM cgc_sinl PROC fld TBYTE PTR[esp+4] jmp _cgc_sin cgc_sinf PROC fld DWORD PTR[esp+4] jmp _cgc_sin cgc_sin PROC fld QWORD PTR[esp+4] _cgc_sin:: fsin fnstsw ax sahf jp _2 ret _2: call cgc_twopi_rem fsin ret _END cgc_sin cgc_cosl PROC fld TBYTE PTR[esp+4] jmp _cgc_cos cgc_cosf PROC fld DWORD PTR[esp+4] jmp _cgc_cos cgc_cos PROC fld QWORD PTR[esp+4] _cgc_cos:: fcos fnstsw ax sahf jp _2 ret _2: call cgc_twopi_rem fcos ret _END cgc_cos cgc_tanl PROC fld TBYTE PTR[esp+4] jmp _cgc_tan cgc_tanf PROC fld DWORD PTR[esp+4] jmp _cgc_tan cgc_tan PROC fld QWORD PTR[esp+4] _cgc_tan:: fptan fnstsw ax sahf jp _2 fstp st(0) ret _2: call cgc_twopi_rem fptan fstp st(0) ret _END cgc_tan cgc_twopi_rem PROC fldpi fadd st(0), st(0) fxch st(1) _1: fprem fnstsw ax sahf jp _1 fstp st(1) ret cgc_twopi_rem ENDP cgc_remainderl PROC fld TBYTE PTR[esp+16] fld TBYTE PTR[esp+4] jmp _cgc_remainder cgc_remainderf PROC fld DWORD PTR[esp+8] fld DWORD PTR[esp+4] jmp _cgc_remainder cgc_remainder PROC fld QWORD PTR[esp+12] fld QWORD PTR[esp+4] _cgc_remainder:: fprem1 fstsw ax sahf jp _cgc_remainder fstp st(1) ret _END cgc_remainder cgc_logl PROC fld TBYTE PTR[esp+4] jmp _cgc_log cgc_logf PROC fld DWORD PTR[esp+4] jmp _cgc_log cgc_log PROC fld QWORD PTR[esp+4] _cgc_log:: fldln2 fxch st(1) fyl2x ret _END cgc_log cgc_log10l PROC fld TBYTE PTR[esp+4] jmp _cgc_log10 cgc_log10f PROC fld DWORD PTR[esp+4] jmp _cgc_log10 cgc_log10 PROC fld QWORD PTR[esp+4] _cgc_log10:: fldlg2 fxch st(1) fyl2x ret _END cgc_log10 cgc_significandl PROC fld TBYTE PTR[esp+4] jmp _cgc_significand cgc_significandf PROC fld DWORD PTR[esp+4] jmp _cgc_significand cgc_significand PROC fld QWORD PTR[esp+4] _cgc_significand:: fxtract fstp st(1) ret _END cgc_significand cgc_scalbnl PROC fild DWORD PTR[esp+16] fld TBYTE PTR[esp+4] jmp _cgc_scalbn cgc_scalbnf PROC fild DWORD PTR[esp+8] fld DWORD PTR[esp+4] jmp _cgc_scalbn cgc_scalbn PROC fild DWORD PTR[esp+12] fld QWORD PTR[esp+4] _cgc_scalbn:: fscale fstp st(1) ret _END cgc_scalbn cgc_scalblnl PROC jmp cgc_scalbnl cgc_scalblnf PROC jmp cgc_scalbnf cgc_scalbln PROC jmp cgc_scalbn _END cgc_scalbln cgc_rintl PROC fld TBYTE PTR[esp+4] jmp _cgc_rint cgc_rintf PROC fld DWORD PTR[esp+4] jmp _cgc_rint cgc_rint PROC fld QWORD PTR[esp+4] _cgc_rint:: frndint ret _END cgc_rint cgc_sqrtl PROC fld TBYTE PTR[esp+4] jmp _cgc_sqrt cgc_sqrtf PROC fld DWORD PTR[esp+4] jmp _cgc_sqrt cgc_sqrt PROC fld QWORD PTR[esp+4] _cgc_sqrt:: fsqrt ret _END cgc_sqrt cgc_fabsl PROC fld TBYTE PTR[esp+4] jmp _cgc_fabs cgc_fabsf PROC fld DWORD PTR[esp+4] jmp _cgc_fabs cgc_fabs PROC fld QWORD PTR[esp+4] _cgc_fabs:: fabs ret _END cgc_fabs cgc_atan2l PROC fld TBYTE PTR[esp+4] fld TBYTE PTR[esp+16] jmp _cgc_atan2 cgc_atan2f PROC fld DWORD PTR[esp+4] fld DWORD PTR[esp+8] jmp _cgc_atan2 cgc_atan2 PROC fld QWORD PTR[esp+4] fld QWORD PTR[esp+12] _cgc_atan2:: fpatan ret _END cgc_atan2 cgc_log2l PROC fld TBYTE PTR[esp+4] jmp _cgc_log2 cgc_log2f PROC fld DWORD PTR[esp+4] jmp _cgc_log2 cgc_log2 PROC fld QWORD PTR[esp+4] _cgc_log2:: fld1 fxch fyl2x ret _END cgc_log2 cgc_exp2l PROC fld TBYTE PTR[esp+4] jmp cgc_exp2x cgc_exp2f PROC fld DWORD PTR[esp+4] jmp cgc_exp2x cgc_exp2 PROC fld QWORD PTR[esp+4] jmp cgc_exp2x cgc_exp2x PROC fld st(0) frndint fsubr st,st(1) fxch f2xm1 fld1 faddp fscale fstp st(1) ret cgc_exp2x ENDP _END cgc_exp2 cgc_powl PROC fld TBYTE PTR[esp+16] fld TBYTE PTR[esp+4] jmp _cgc_pow cgc_powf PROC fld DWORD PTR[esp+8] fld DWORD PTR[esp+4] jmp _cgc_pow cgc_pow PROC fld QWORD PTR[esp+12] fld QWORD PTR[esp+4] _cgc_pow:: fyl2x jmp cgc_exp2x _END cgc_pow cgc_expl PROC fld TBYTE PTR[esp+4] jmp _cgc_exp cgc_expf PROC fld DWORD PTR[esp+4] jmp _cgc_exp cgc_exp PROC fld QWORD PTR[esp+4] _cgc_exp:: fldl2e fmulp jmp cgc_exp2x _END cgc_exp cgc_setjmp PROC mov ecx, [esp+4] mov edx, [esp+0] mov [ecx+0], edx mov [ecx+4], ebx mov [ecx+8], esp mov [ecx+12], ebp mov [ecx+16], esi mov [ecx+20], edi xor eax, eax ret cgc_setjmp ENDP cgc_longjmp PROC mov edx, [esp+4] mov eax, [esp+8] mov ecx, [edx+0] mov ebx, [edx+4] mov esp, [edx+8] mov ebp, [edx+12] mov esi, [edx+16] mov edi, [edx+20] test eax, eax jnz _1 inc eax _1: mov [esp+0], ecx ret cgc_longjmp ENDP END
; A016138: Expansion of 1/((1-3x)(1-7x)). ; 1,10,79,580,4141,29230,205339,1439560,10083481,70604050,494287399,3460188940,24221854021,169554572470,1186886790259,8308221880720,58157596211761,407103302622490,2849723505777919,19948065702706900,139636463405732701,977455254300482110,6842186811484434379,47895307774534219480,335267154704169072841,2346870083776472119330,16428090588977170663639,114996634130465792130460,804976438936137337368181,5634835072621591738942150,39443845508557033304689699,276106918560516906529111840,1932748429925471365892634721,13529239009483858621814998570,94704673066403687534404656559,662932711464875844285931595620,4640528980254281004636818168461,32483702861780417316363618176590,227385920032464272066263000228219,1591701440227253957018994020573800,11141910081590789856798417200945401,77993370571135565470585297577404210,545953593997949067713086214554188679 add $0,1 mov $1,3 pow $1,$0 mov $2,7 pow $2,$0 sub $2,$1 mov $0,$2 mul $0,4 div $0,16
; unsigned char ulap_pent_from_attr_paper(unsigned char attr) SECTION code_clib SECTION code_arch PUBLIC _ulap_pent_from_attr_paper EXTERN asm_ulap_pent_from_attr_paper _ulap_pent_from_attr_paper: pop af pop hl push hl push af jp asm_ulap_pent_from_attr_paper
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Hookshot ; General-purpose library for injecting DLLs and hooking function calls. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Authored by Samuel Grossman ; Copyright (c) 2019-2021 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; INCLUDE TestDefinitions.inc ; Exercises Hookshot's instruction transplant ability with instructions that include forward rel32 branch displacements that target instructions well outside the area being transplanted. ; This test requires that Hookshot correctly modify the branch displacement of a jump instruction. If it gets the new displacement incorrect, the function's return value will also be incorrect. ; Hook function does nothing special for this test. _TEXT SEGMENT BEGIN_HOOKSHOT_TEST_FUNCTION JumpForwardRel32_Original mov sax, scx jmp near ptr $return REPEAT 400 inc eax ENDM ; If Hookshot does not get the rewritten rel32 branch displacement perfect, the IP will land in one of the two surrounding banks of inc instructions. ; Because sax is loaded with the expected return value before the jump, any inc instruction will cause an incorrect return value. $return: ret REPEAT 400 inc eax ENDM jmp $return END_HOOKSHOT_TEST_FUNCTION JumpForwardRel32_Original BEGIN_HOOKSHOT_TEST_FUNCTION JumpForwardRel32_Hook mov sax, scx shl sax, 1 ret END_HOOKSHOT_TEST_FUNCTION JumpForwardRel32_Hook _TEXT ENDS END
/* P N T S _ B R E P . C P P * BRL-CAD * * Copyright (c) 2012-2014 United States Government as represented by * the U.S. Army Research Laboratory. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this file; see the file named COPYING for more * information. */ /** @file pnts_brep.cpp * * The b-rep conversion of primitive PNTS (Point Cloud) should be * ignored. Return a NULL ON_Brep pointer. * */ #include "common.h" #include "raytrace.h" #include "rt/geom.h" #include "brep.h" extern "C" void rt_pnts_brep(ON_Brep **b, const struct rt_db_internal *ip, const struct bn_tol *) { struct rt_pnts_internal *pip; RT_CK_DB_INTERNAL(ip); pip = (struct rt_pnts_internal *)ip->idb_ptr; RT_PNTS_CK_MAGIC(pip); *b = NULL; } // Local Variables: // tab-width: 8 // mode: C++ // c-basic-offset: 4 // indent-tabs-mode: t // c-file-style: "stroustrup" // End: // ex: shiftwidth=4 tabstop=8
/** * @file padding.hpp * @author Saksham Bansal * * Definition of the Padding class that pads the incoming data. * * mlpack is free software; you may redistribute it and/or modify it under the * terms of the 3-clause BSD license. You should have received a copy of the * 3-clause BSD license along with mlpack. If not, see * http://www.opensource.org/licenses/BSD-3-Clause for more information. */ #ifndef MLPACK_METHODS_ANN_LAYER_PADDING_HPP #define MLPACK_METHODS_ANN_LAYER_PADDING_HPP #include <mlpack/prereqs.hpp> #include <mlpack/methods/ann/layer/layer_traits.hpp> namespace mlpack { namespace ann /** Artificial Neural Network. */ { /** * Implementation of the Padding module class. The Padding module applies a bias term * to the incoming data. * * @tparam InputDataType Type of the input data (arma::colvec, arma::mat, * arma::sp_mat or arma::cube). * @tparam OutputDataType Type of the output data (arma::colvec, arma::mat, * arma::sp_mat or arma::cube). */ template < typename InputDataType = arma::mat, typename OutputDataType = arma::mat > class Padding { public: /** * Create the Padding object using the specified number of output units. * * @param padWLeft Left padding width of the input. * @param padWLeft Right padding width of the input. * @param padHTop Top padding height of the input. * @param padHBottom Bottom padding height of the input. */ Padding(const size_t padWLeft = 0, const size_t padWRight = 0, const size_t padHTop = 0, const size_t padHBottom = 0); /** * Ordinary feed forward pass of a neural network, evaluating the function * f(x) by propagating the activity forward through f. * * @param input Input data used for evaluating the specified function. * @param output Resulting output activation. */ template<typename eT> void Forward(const arma::Mat<eT>&& input, arma::Mat<eT>&& output); /** * Ordinary feed backward pass of a neural network, calculating the function * f(x) by propagating x backwards trough f. Using the results from the feed * forward pass. * * @param input The propagated input activation. * @param gy The backpropagated error. * @param g The calculated gradient. */ template<typename eT> void Backward(const arma::Mat<eT>&& /* input */, const arma::Mat<eT>&& gy, arma::Mat<eT>&& g); //! Get the output parameter. OutputDataType const& OutputParameter() const { return outputParameter; } //! Modify the output parameter. OutputDataType& OutputParameter() { return outputParameter; } //! Get the delta. OutputDataType const& Delta() const { return delta; } //! Modify the delta. OutputDataType& Delta() { return delta; } /** * Serialize the layer. */ template<typename Archive> void serialize(Archive& ar, const unsigned int /* version */); private: //! Locally-stored left padding width. size_t padWLeft; //! Locally-stored right padding width. size_t padWRight; //! Locally-stored top padding height. size_t padHTop; //! Locally-stored bottom padding height. size_t padHBottom; //! Locally-stored number of rows and columns of input. size_t nRows, nCols; //! Locally-stored delta object. OutputDataType delta; //! Locally-stored output parameter object. OutputDataType outputParameter; }; // class Padding } // namespace ann } // namespace mlpack // Include implementation. #include "padding_impl.hpp" #endif
; A268165: Number of n X 2 0..3 arrays with every repeated value in every row and column one larger mod 4 than the previous repeated value, and upper left element zero. ; Submitted by Christian Krause ; 4,64,900,12100,155236,1932100,23444964,278956804,3265665316,37722185284,430853083236,4874266035076,54692207394724,609340042214596,6746970728882916,74302629109627396,814375880067172900,8888086045321534276,96640107665246123364,1047243278414510006404,11314381171962349921444,121910109482126919453124,1310360047475551170992100,14053549651633700372272900,150423787949288955833716516,1607172817589996357802002500,17143358171147033477110844004,182591499925814162949752135044,1942110696516650799452656470436 seq $0,268164 ; Number of n X 1 0..3 arrays with every repeated value in every row and column one larger mod 4 than the previous repeated value, and upper left element zero. pow $0,2 mul $0,4
;================================================= ; Name: Moya, Branden ; Username: bmoya001@ucr.edu ; ; Lab: lab 1 ; Lab section: 021 ; TA: Bryan Marsh ; ;================================================= .Orig x3000 ;Instructions HALT ;Local data .end
; ; Copyright (c) 2020 Bitdefender ; SPDX-License-Identifier: Apache-2.0 ; STRUC PCPU .Self resq 1 .Id resd 1 .BootInfoIndex resd 1 .VmxActivated resb 1 .IsIntel resb 1 .Vcpu resq 1 .VmxOnPa resq 1 .TempRCX resq 1 .TopOfStack resq 1 .UseXsave resb 1 .UseXsaveopt resb 1 .FpuSaveSize resd 1 .Xcr0AvailMaskLow resd 1 .Xcr0AvailMaskHigh resd 1 ENDSTRUC
.386 .model flat, stdcall option casemap :none include \MASM32\INCLUDE\windows.inc include \MASM32\INCLUDE\kernel32.inc include \MASM32\INCLUDE\user32.inc includelib \MASM32\LIB\kernel32.lib includelib \MASM32\LIB\user32.lib _OPCODE struct dwOldAddress dd ? dwNewAddress dd ? dwJumpAddress dd ? dwLength dd ? _OPCODE ends .code test_code: @@: jmp @F mov eax, edx pop eax push eax call @F cmp eax, 0 jne @B jmp @B add ecx, edx add eax, edx xchg edx, ecx call @B jne @F db 0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0 jne @B ret @@: ret int 3 include Catchy32\Catchy32.inc get_jump_address proc dwCurrentAddress : DWORD push ecx push edi mov edi, dwCurrentAddress mov al, byte ptr [edi] cmp al, 070h jl @F cmp al, 07Fh jna @_jump_imm8_ @@: cmp al, 0EBh je @_jump_uncond_imm8_ cmp al, 00Fh jne @F mov ah, byte ptr [edi + 1] cmp ah, 080h jl @F cmp ah, 08Fh jna @_jump_imm32_ @@: cmp al, 0E9h je @_jump_uncond_imm32_ cmp al, 0E8h je @_call_imm32_ jmp @_exit_ @_jump_imm8_: @_jump_uncond_imm8_: movzx eax, byte ptr [edi + 1] mov cl, al test cl, 10000000b jnz @_neg_1 add edi, eax add edi, 2 xchg eax, edi jmp @_exit_ @_neg_1: neg al sub al, 2 sub edi, eax xchg eax, edi jmp @_exit_ @_jump_imm32_: mov eax, dword ptr [edi + 2] mov ecx, eax shr ecx, 24d test ecx, 10000000b jnz @_neg_2 add eax, edi add eax, 6 jmp @_exit_ @_neg_2: neg eax sub eax, 6 sub edi, eax xchg eax, edi jmp @_exit_ @_jump_uncond_imm32_: @_call_imm32_: mov eax, dword ptr [edi + 1] mov ecx, eax shr ecx, 24d test ecx, 10000000b jnz @_neg_3 add edi, eax add edi, 5 xchg eax, edi jmp @_exit_ @_neg_3: neg eax sub eax, 5 sub edi, eax xchg eax, edi @_exit_: pop edi pop ecx ret get_jump_address endp get_new_jump_address proc dwAddress:DWORD, pOpcodes : DWORD push ecx assume ecx : ptr _OPCODE mov ecx, pOpcodes mov eax, dwAddress @@: cmp [ecx].dwOldAddress, eax je @F add ecx, sizeof _OPCODE cmp [ecx].dwOldAddress, 0 jne @B xor eax, eax @@: mov eax, [ecx].dwNewAddress pop ecx ret get_new_jump_address endp MorphCode proc dwCodeAddress : DWORD, dwOutputBuffer : DWORD local pOpcodes : DWORD local dwTotalCodeSize : DWORD invoke VirtualAlloc, NULL, 1024*1024, MEM_COMMIT + MEM_RESERVE, PAGE_READWRITE mov pOpcodes, eax push 0 pop dwTotalCodeSize assume ecx : ptr _OPCODE mov esi, dwCodeAddress ; Code Address mov edi, dwOutputBuffer ; New Code Address mov ecx, pOpcodes ; array of _OPCODES mov [ecx].dwNewAddress, edi @_loop_1: call c_Catchy mov [ecx].dwOldAddress, esi mov [ecx].dwLength, eax cmp byte ptr [esi], 070h jl @F cmp byte ptr [esi], 07Fh ja @F push eax mov al, 00Fh stosb movzx eax, byte ptr [esi] add eax, 10h stosd push esi call get_jump_address mov [ecx].dwJumpAddress, eax pop eax add dwTotalCodeSize, 6 jmp @_next_inst_ @@: cmp byte ptr [esi], 0EBh jne @F push eax mov al, 0E9h stosb xor eax, eax stosd push esi call get_jump_address mov [ecx].dwJumpAddress, eax pop eax add dwTotalCodeSize, 5 jmp @_next_inst_ @@: cmp byte ptr [esi], 0E9h jne @F push eax push esi call get_jump_address mov [ecx].dwJumpAddress, eax pop eax jmp @_replace_instr_ @@: cmp byte ptr [esi], 0E8h jne @F push eax push esi call get_jump_address mov [ecx].dwJumpAddress, eax pop eax jmp @_replace_instr_ @@: cmp byte ptr [esi], 00Fh jne @F cmp byte ptr [esi + 1], 080h jl @F cmp byte ptr [esi + 1], 08Fh ja @F push eax push esi call get_jump_address mov [ecx].dwJumpAddress, eax pop eax @@: @_replace_instr_: push esi push ecx mov ecx, eax rep movsb pop ecx pop e
/** * Copyright Soramitsu Co., Ltd. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 */ #include "host_api/impl/io_extension.hpp" #include <runtime/wasm_result.hpp> namespace kagome::host_api { IOExtension::IOExtension(std::shared_ptr<runtime::WasmMemory> memory) : memory_(std::move(memory)), logger_{common::createLogger(kDefaultLoggerTag)} { BOOST_ASSERT_MSG(memory_ != nullptr, "memory is nullptr"); } void IOExtension::ext_print_hex(runtime::WasmPointer data, runtime::WasmSize length) { const auto &buf = memory_->loadN(data, length); logger_->info("hex value: {}", buf.toHex()); } void IOExtension::ext_logging_log_version_1( runtime::WasmEnum level, runtime::WasmSpan target, runtime::WasmSpan message) { using runtime::WasmResult; using runtime::WasmLogLevel; auto read_str_from_position = [&] (WasmResult location) { return memory_->loadStr(location.address, location.length); }; const auto target_str = read_str_from_position(WasmResult(target)); const auto message_str = read_str_from_position(WasmResult(message)); switch (level) { case WasmLogLevel::WasmLL_Error: logger_->error( "target: {}\n\tmessage: {}", target_str, message_str); break; case WasmLogLevel::WasmLL_Warn: logger_->warn( "target: {}\n\tmessage: {}", target_str, message_str); break; case WasmLogLevel::WasmLL_Info: logger_->info( "target: {}\n\tmessage: {}", target_str, message_str); break; case WasmLogLevel::WasmLL_Debug: logger_->debug( "target: {}\n\tmessage: {}", target_str, message_str); break; case WasmLogLevel::WasmLL_Trace: logger_->trace( "target: {}\n\tmessage: {}", target_str, message_str); break; default: { assert(false); logger_->error( "Message with incorrect log level. Target: {}\n\tmessage: {}", target_str, message_str); } } } void IOExtension::ext_print_num(uint64_t value) { logger_->info("number value: {}", value); } void IOExtension::ext_print_utf8(runtime::WasmPointer utf8_data, runtime::WasmSize utf8_length) { const auto data = memory_->loadStr(utf8_data, utf8_length); logger_->info("string value: {}", data); } } // namespace kagome::host_api
; vim: set syntax=z80: ; Trim AuditAssert's from the release build #cflags -DNAUDIT _project_start equ 0x8000 #target BIN #code _HEADER, _project_start #code _GSINIT #code _HOME #code _CODE #code _INITIALIZER #data _INITIALIZED, _INITIALIZER, _INITIALIZER_size #code _CABS, _INITIALIZER_end, 0 #code _GSFINAL, *, 0 #data _DATA #data _DABS, *, 0 #data _RSEG, *, 0 #include "start.asm" #include "interrupts.asm" #include "halt.asm" #include "handle_interrupt.c" #include "string.asm" #include "xarray.c" #include "main.c" #include "graphics.c" #include "graphics.asm" #include "util.asm" #include "util.c" #include "font.asm" #include "text.c" #include "text.asm" #include "assert.c" #include "allocator.c" #include "keyboard.c" #include "editor.c" #include standard library ; Must come last #code _GSINIT ret
org $008921 ; Routine to hack BCS $15 ; Change branch op (seems to let at least 05-06 without encounters)
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1991 -- All Rights Reserved PROJECT: PC GEOS MODULE: PostScript Translation Library FILE: exportText.asm AUTHOR: Jim DeFrisco, 21 March 1991 ROUTINES: Name Description ---- ----------- EmitTextField generate code for GrDrawTextField REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 3/21/91 Initial revision DESCRIPTION: This file contains all the text-related output code $Id: exportText.asm,v 1.1 97/04/07 11:25:42 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ExportText segment resource ; GetPathOrDrawGState ; The text code is called from either the normal text drawing part of the ; translation library, or the path creation part. This macro fetches the right ; GState handle to use. GetPathOrDrawGState macro reg local done mov reg, tgs.TGS_pathGState tst reg jnz done mov reg, tgs.TGS_gstate done: endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitTextField %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Generate code for a GrDrawTextField element CALLED BY: INTERNAL TranslateGString PASS: si - handle to gstring bx - gstring opcode (in kind of a twisted way) tgs - inherited local stack frame RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: For GrDrawTextField elements, the text is drawn as a group of consecutive style runs (I call this a styles group). A styles group can represent an entire GrDrawTextField element, or just a subset. The difference is that the styles group does not have any embedded graphics. Each style group is passed on the stack as an array of style runs. Each style run is an array of other info. The structure of a style run is: [(string) {attr-info} <track kern> <style matrix> <font> <size>] where: (string) - the text string to draw, in parens {attr-info} - commands to set attributes, in curly braces <track kern> - track kerning for style run <style-matrix> - transformation matrix to effect the current style <font> - a valid PostScript font name <size> - the current pointsize These style runs are then strung together on the stack: [ [style-run] [style-run] ... ] Finally, the styles group is followed by the space padding, the string width (under GEOS) and the position KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitTextField proc far uses ax, bx, cx, si, di, dx, es tgs local TGSLocals .enter inherit ; we need to output all that stuff to start an object, output ; the transform, etc, etc. call EmitStartObject call EmitTransform call ExtractElement GetPathOrDrawGState di ; get right gstate handle mov tgs.TGS_locmot.WWF_int, 0 ; init local motion mov tgs.TGS_locmot.WWF_frac, 0 ; init local motion ; get the size of the string mov bx, si ; ds:bx -> element mov cx, ds:[bx].ODTF_saved.GDFS_nChars ; cx = stringlen ; set up ds:si to point at style runs mov si, size OpDrawTextField ; bx.si -> 1st style run ; alright, we're ready to go. The following pointers are set: ; ds:bx -> pointer to a OpDrawTextField structure ; ds:bx.si -> pointer to first TFStyleRun structure ; cx - # characters in the line ; before we loop through the style runs, we need to init some ; variables. We're keeping track of the total width of the ; field, so init the variable mov tgs.TGS_width.WWF_frac, 0 ; zero total field wid mov tgs.TGS_width.WWF_int, 0 mov ax, ds:[bx].ODTF_saved.GDFS_drawPos.PWBF_x.WBF_int mov tgs.TGS_gpos.WWF_int, ax mov ah, ds:[bx].ODTF_saved.GDFS_drawPos.PWBF_x.WBF_frac clr al mov tgs.TGS_gpos.WWF_frac, ax ; loop through the style runs, getting out the attributes call HandleStyleGroup ; handle next group of runs ; all done mov bx, tgs.TGS_chunk.handle ; unlock block call MemUnlock ; release string block .leave ret EmitTextField endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% HandleStyleGroup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Handle a series of text-only style runs of a GrDrawTextField element CALLED BY: INTERNAL EmitTextField PASS: ds:bx - pointer to element ds:bx+si - pointer to TFStyleRun structure cx - #chars to draw in group di - gstate handle RETURN: nothing DESTROYED: ax PSEUDO CODE/STRATEGY: each style group is output in the following format [ array of style runs ] <spacepad> <stringwidth> x y DSG KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 06/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ HandleStyleGroup proc near uses es, di tgs local TGSLocals .enter inherit ; now we need to emit the opening bracket for the array of ; style run arrays. push ds, bx, cx, dx mov bx, handle PSCode call MemLock mov ds, ax ; ds -> PSCode resource mov bx, tgs.TGS_stream EmitPS emitOpenBracket mov bx, handle PSCode call MemUnlock pop ds, bx, cx, dx ; as we output each style run, we want to keep track of ; the total length, so zero it out right now. mov tgs.TGS_gwidth.WWF_frac, 0 mov tgs.TGS_gwidth.WWF_int, 0 ; while there are still characters left, keep outputting the ; style run arrays. styleRunLoop: call HandleStyleRun jc done ; done if hit embedded graphic tst cx ; ...might be done jnz styleRunLoop ; ...but maybe not ; all that is left is the closing bracket, the invocation of ; our PostScript procedure, and the EndObject stuff done: push si, cx ; save count to return push ds, bx movwbf diah, ds:[bx].ODTF_saved.GDFS_drawPos.PWBF_y addwbf diah, ds:[bx].ODTF_saved.GDFS_baseline rndwbf diah push di push tgs.TGS_gpos.WWF_frac push tgs.TGS_gpos.WWF_int mov ax, tgs.TGS_gwidth.WWF_frac ; add with into current pos add tgs.TGS_gpos.WWF_frac, ax mov ax, tgs.TGS_gwidth.WWF_int adc tgs.TGS_gpos.WWF_int, ax segmov es, ss, di lea di, tgs.TGS_buffer ; es:di -> string buffer mov bx, handle PSCode call MemLock mov ds, ax ; ds -> PSCode resource mov si, offset emitCloseBracket mov cx, length emitCloseBracket rep movsb ; write out space padding push di GetPathOrDrawGState di ; get right handle call GrGetTextSpacePad ; dxbl = padding pop di mov ah, bl mov bx, dx clr al call WWFixedToAscii ; convert to ascii mov al, ' ' ; space delimit things stosb ; write out group width mov bx, tgs.TGS_gwidth.WWF_int ; write out width mov ax, tgs.TGS_gwidth.WWF_frac call WWFixedToAscii ; convert to ascii mov al, ' ' stosb ; write out x pos pop bx ; restore x pos pop ax tst tgs.TGS_xfactor ; see if OK jnz xOK clr ax clr bx xOK: call WWFixedToAscii mov al, ' ' stosb ; write out y pos pop bx clr ax tst tgs.TGS_yfactor ; see if OK jnz yOK clr bx yOK: call WWFixedToAscii ; write Y POS mov al, ' ' stosb mov si, offset emitDSG mov cx, length emitDSG tst tgs.TGS_pathGState ; if a path, use diff opcode jz copyOp mov si, offset emitPSG mov cx, length emitPSG copyOp: rep movsb call EmitBuffer ; write it all out mov bx, handle PSCode call MemUnlock pop ds, bx call EmitEndObject ; last part... pop si, cx ; restore remaining char count .leave ret HandleStyleGroup endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% HandleStyleRun %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Handle a single style run of a GrDrawTextField element CALLED BY: INTERNAL HandleStyleGroup PASS: ds:bx - pointer to element ds:bx+si - pointer to TFStyleRun structure cx - #chars still left to draw (before this run) di - gstate handle es - points to locked options block RETURN: ds:bx.si - pointer to next StyleRun cx - #chars still left to draw (after this run) DESTROYED: ax, dx PSEUDO CODE/STRATEGY: The structure of a Style run (as a PostScript data element) is as follows: [(this is the string) {attr setting} <track kern> <style matrix> <font> <point size> ] KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 06/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ HandleStyleRun proc near uses es, di tgs local TGSLocals .enter inherit ; setup pointer to text. mov dx, si ; setup dx -> string add dx, bx add dx, size TFStyleRun ; ds:dx -> characters ; now check for hyphen cmp cx, ds:[bx][si].TFSR_count ; if total remain = this run jne dealtWithHyphen call CheckAutoHyphen ; add hyphen if needed mov ds:[bx][si].TFSR_count, cx ; save new count dealtWithHyphen: push cx ; save #chars left (total) mov cx, ds:[bx][si].TFSR_count ; get character count ; need to handle some Greek characters differently, since they ; don't appear in the StandardEncoding vector for PostScript. ; Hrmph. call ConquerTheGreeks ; Yeah, it's late.... jnc doTheWork ; no greeks mov dx, cx ; set up #chars here jmp doneRun ; we want to skip over single tab characters. Check for ; a one-character run, then check to see if is a tab. doTheWork: cmp cx, 1 ; one character ? jne addressStyleRun ; no, continue push si ; save a reg mov si, dx cmp {byte} ds:[si], C_TAB ; is it a tab ? pop si jne addressStyleRun ; no, continue mov dx, 1 ; #chars in this run jmp doneRun ; exit early ; set all the attributes in the GState for this run addressStyleRun: add si, bx ; ds:si -> TFStyleRun add si, TFSR_attr ; point to attributes ; we have to handle the space padding separately, since ; it gets hosed by the text field element storing routine ; in the kernel. sigh. push di, dx, bx GetPathOrDrawGState di ; get right handle call GrGetTextSpacePad ; get space padding movwbf ds:[si].TA_spacePad, dxbl pop di, dx, bx call GrSetTextAttr ; set the text attributes sub si, TFSR_attr sub si, bx ; things back to normal ; calculate the width of this run, and add it into the ; running total for the whole group push si, dx ; save the offset mov si, dx ; ds:si -> string call GrTextWidthWBFixed ; figure out how wide add tgs.TGS_gwidth.WWF_frac.high, ah ; update group width adc tgs.TGS_gwidth.WWF_int, dx add tgs.TGS_width.WWF_frac.high, ah ; adc tgs.TGS_width.WWF_int, dx pop si, dx ; restore the offset ; send out the string and attributes push cx ; save #chars in this run ; before we do it, check to make sure that we don't begin with ; a tab. If we do, lop it off push si mov si, dx cmp {byte} ds:[si], C_TAB ; is it a tab ? jne tabHandled inc dx ; skip over the tab dec cx tabHandled: pop si call EmitTextString ; emit "[(string},NL" call EmitTextAttr ; emit "{ pscode},NL" push es:[PSEO_fonts] ; save font list enum segmov es, ss, di lea di, tgs.TGS_buffer ; es:di -> string buffer mov ch, ds:[bx][si].TFSR_attr.TA_trackKern.low clr cl mov al, ds:[bx][si].TFSR_attr.TA_trackKern.high cbw mov dx, ax push bx mov ah, ds:[bx][si].TFSR_attr.TA_size.WBF_frac mov bx, ds:[bx][si].TFSR_attr.TA_size.WBF_int ; get size clr al call GrMulWWFixed ; bx.ax = track kern in pts mov bx, dx mov ax, cx call WWFixedToAscii mov al, ' ' ; put in the separator stosb pop bx pop ax ; restore font list enum push bx mov bx, ax call EmitFont ; write style matrix and font pop bx push bx mov ah, ds:[bx][si].TFSR_attr.TA_size.WBF_frac mov bx, ds:[bx][si].TFSR_attr.TA_size.WBF_int ; get p size clr al call WWFixedToAscii mov al, tgs.TGS_newstyle ; get leftover style bits call EmitStyleMatrix push ds, si mov bx, handle PSCode call MemLock mov ds, ax mov si, offset emitCloseBracket mov cx, length emitCloseBracket rep movsb mov si, offset emitCRLF mov cx, length emitCRLF rep movsb call EmitBuffer pop ds, si ; restore style run pointer mov bx, handle PSCode call MemUnlock pop bx ; ds:bx <- base of element pop dx ; restore #chars in this run doneRun: pop cx ; restore #characters total sub cx, dx ; calc #chars left add si, size TFStyleRun ; bump to next style run add si, dx ; bump past chars too clc ; not an embedded graphic .leave ret HandleStyleRun endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ConquerTheGreeks %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Since the standard character set in PS doesn't have these greek chars that are in our standard set, we add a few special style runs to take care of them. CALLED BY: INTERNAL HandleStyleRun PASS: ds:bx - pointer to element ds:bx+si - pointer to TFStyleRun structure ds:dx - pointer to text to draw cx - #chars in this style run di - gstate handle es - points to locked options block RETURN: carry - set if we've finished with the style run everything else intact DESTROYED: nothing PSEUDO CODE/STRATEGY: scan the string for suspicious chars. If any found, kill them. No, actually, just take them prisoner. KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 05/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ; returns carry if char in al is a greek one, assumes es == cs, trashes di FindAGreek macro local done local maybeLast mov di, offset greekCharTab ; reset pointer push cx ; save count mov cx, LEN_GREEK_TAB ; set up repne scasb ; look for character in table stc ; assume found it jcxz maybeLast jmp done ; found something.. ; we might have something. Check to see if we're on the last maybeLast: je done ; nothing, continue clc done: pop cx ; restore count endm ;-------------------------------------------------------------------- ConquerTheGreeks proc near uses ax, cx, dx, si, es, di tgs local TGSLocals .enter inherit ; for now, don't deal with this routine. clc jnc done ; if this style run is in Symbol font, then bail mov ax, ds:[bx][si].TFSR_attr.TA_font and ax, 0x0fff ; isolate face ID cmp ax, (FID_DTC_URW_SYMBOLPS and 0x0fff) je doneOK ; if this is a font that we don't have to re-encode (either ; because it's a dingbats type font or because we're going to ; download it) then just bail. mov ax, ds:[bx][si].TFSR_attr.TA_font ; get the font id push si, dx, cx mov dl, ds:[bx][si].TFSR_attr.TA_styleSet mov si, tgs.TGS_pageFonts.chunk ; get chunk handle mov si, ds:[si] ; deref chunk mov cx, ds:[si].PF_count ; get #fonts in array add si, offset PF_first + size PageFont ; go to first font searchLoop: cmp ax, ds:[si].PF_id ; see if we have this jne nextEntry cmp dl, ds:[si].PF_style ; check style too jne nextEntry test ds:[si].PF_flags, mask PFF_REENCODE ; bail if not reenc jnz tryGreeks ; look for greeks pop si, dx, cx jmp doneOK nextEntry: add si, size PageFont loop searchLoop ; OK, we're gonna search the string for Greek dudes. tryGreeks: pop si, dx, cx mov tgs.TGS_bmWidth, ax ; save the font. segmov es, cs, di ; set es:di -> greek char table mov di, offset greekCharTab ; scan the string. if none found, leave. push si, cx mov si, dx scanLoop: lodsb ; get character cmp al, C_DAGGER ; below this is OK jbe keepLooking cmp al, C_LY_DIERESIS ; from here on OK jb dangerZone keepLooking: loop scanLoop pop si, cx ; we made it OK, exit doneOK: clc ; signal we're not finished done: .leave ret ;---------------------------------------------------------------- ; in the danger zone. Do more checking ; there are 18 characters that we're looking for. dangerZone: FindAGreek jnc keepLooking ; nothing, continue ;---------------------------------------------------------------- ; we found something greek. now the real fun begins ; basically, we want to loop through each sub-style run, ; grouping together all verbotten characters. Til we're ; done with the whole style run. But you knew that. mov ax, si dec ax pop si, cx ; restore original values cmp ax, dx ; is it the first letter ? je DoGreek ; first char is greek... ; next style run should be Roman ; cx = #chars left in overall style run ; ds:dx -> next character ; ds:bx.si -> TFStyleRun struct DoRoman: mov ax, tgs.TGS_bmWidth ; we stored original fontID here mov ds:[bx][si].TFSR_attr.TA_font, ax ; restore font push bx ; save element pointer mov bx, dx ; ds:bx -> string getNextRomanChar: mov al, ds:[bx] ; get next char FindAGreek jc doneWithRomanRun inc bx ; on to check next character mov ax, bx ; see if we're done sub ax, dx cmp ax, cx jb getNextRomanChar doneWithRomanRun: mov ax, bx ; calc #chars in this run sub ax, dx ; ax = #chars in this run pop bx ; restore element pointer mov ds:[bx][si].TFSR_count, ax ; store fake count mov es, tgs.TGS_options ; grab options block addr GetPathOrDrawGState di ; get right handle call HandleStyleRun jcxz doneRuns sub si, size TFStyleRun ; back it up segmov es, cs, di ; next style run should be Greek ; cx = #chars left in overall style run ; ds:dx -> next character ; ds:bx.si -> TFStyleRun struct DoGreek: mov ds:[bx][si].TFSR_attr.TA_font, FID_PS_SYMBOL ; set font push bx ; save element pointer mov bx, dx ; ds:bx -> string getNextGreekChar: mov al, ds:[bx] ; get next char FindAGreek jnc doneWithGreekRun sub di, (offset greekCharTab) + 1 mov al, cs:greekMapTab[di] ; get Symbol font character mov ds:[bx], al ; store new character code inc bx ; on to check next character mov ax, bx ; see if we're done sub ax, dx cmp ax, cx jb getNextGreekChar doneWithGreekRun: mov ax, bx ; calc #chars in this run sub ax, dx ; ax = #chars in this run pop bx ; restore element pointer mov ds:[bx][si].TFSR_count, ax ; store fake count mov es, tgs.TGS_options ; grab options block addr GetPathOrDrawGState di ; get right handle call HandleStyleRun jcxz doneRuns sub si, size TFStyleRun ; back it up segmov es, cs, di jmp DoRoman doneRuns: stc jmp done ConquerTheGreeks endp ; These are the GEOS characters that do not appear in the ; standard PostScript font set, but do appear in the Symbol ; font. greekCharTab label char char C_DEGREE, C_NOTEQUAL, C_INFINITY, C_PLUSMINUS char C_LESSEQUAL, C_GREATEREQUAL, C_L_MU, C_L_DELTA char C_U_SIGMA, C_U_PI, C_L_PI, C_INTEGRAL char C_U_OMEGA, C_ROOT, C_APPROX_EQUAL, C_U_DELTA char C_DIVISION, C_DIAMONDBULLET LEN_GREEK_TAB = 18 ; these are the character codes for the above GEOS characters ; in the standard Symbol font encoding under PostScript greekMapTab label char char 0xb0, 0xb9, 0xa5, 0xb1, 0xa3, 0xb3, 0x6d, 0x64 char 0x53, 0x50, 0x70, 0xf2, 0x57, 0xd6, 0xbb, 0x44 char 0xb8, 0xe0 COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitTextString %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Write out a style run string CALLED BY: GLOBAL PASS: ds:dx - pointer to character string cx - #characters in style run RETURN: nothing DESTROYED: ax PSEUDO CODE/STRATEGY: This code extracts the characters from the text field, and emits a "[(this is the string) " sequence to the stream. It may be changed in the future to detect characters from the symbol font and emit separate style runs for those characters. KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 04/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitTextString proc near uses es, dx, si, di, cx tgs local TGSLocals .enter inherit ; set up es:di -> buffer segmov es, ss, di lea di, tgs.TGS_buffer ; es:di -> string buffer mov al, '[' stosb mov al, '(' stosb push si mov si, dx lea dx, tgs.TGS_buffer ; set dx = last buffer pos add dx, (size TGS_buffer) - 8 lastLoop: lodsb call CheckSpecialChars jc charDone stosb ; copy string to buffer charDone: cmp di, dx ; if past, write out buffer ja bufferFull nextChar: loop lastLoop mov al, ')' mov ah, ' ' stosw mov al, C_CR mov ah, C_LF stosw call EmitBuffer pop si .leave ret ; string is too big for one buffer-full, split it up bufferFull: call EmitBuffer ; write out the buffer lea di, tgs.TGS_buffer ; reset pointer jmp nextChar EmitTextString endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CheckSpecialChars %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Write out a character above 0x7f, or some other special chars CALLED BY: INTERNAL EmitTextString PASS: al - character code es:di - where to write it cx - characters left in style run RETURN: al - last char of octal digit carry - clear if we need to store what is in al DESTROYED: ah PSEUDO CODE/STRATEGY: chage code to octal and write it out like \ooo KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 04/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CheckSpecialChars proc near uses bx, cx .enter tst al ; see if >128 js upper128 cmp al, C_LEFT_PAREN ; check for other chars je precedeBackslash cmp al, C_RIGHT_PAREN je precedeBackslash cmp al, C_BACKSLASH je precedeBackslash cmp al, C_NULL_WIDTH je omitChar cmp al, C_OPTHYPHEN jne okDone cmp cx, 1 jne omitChar mov al, C_HYPHEN okDone: clc done: .leave ret precedeBackslash: mov {byte} es:[di], C_BACKSLASH inc di jmp okDone upper128: mov {byte} es:[di], C_BACKSLASH ; write out backslash inc di clr ah mov bx, ax ; save it mov cl, 6 ; shift amount for first letter shr bx, cl ; get high two bits mov cl, cs:octalDigits[bx] ; get this digit mov es:[di], cl inc di mov bx, ax mov cl, 3 shr bx, cl and bx, 7 mov cl, cs:octalDigits[bx] mov es:[di], cl inc di mov bx, ax and bx, 7 mov al, cs:octalDigits[bx] jmp okDone ; get rid of the character omitChar: stc ; signal no store jmp done CheckSpecialChars endp octalDigits label char char "01234567" COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitTextAttr %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get/write the current text attributes CALLED BY: INTERNAL HandleStyleRun PASS: see HandleStyleRun, above ds:dx - pointer to string cx - #characters RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: puts out a set of postscript commands to set some attributes, all in a set of curly braces. KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitTextAttr proc near uses es, dx, si, di, cx, ds, ax, bx tgs local TGSLocals .enter inherit ; set up es:di -> buffer segmov es, ss, di lea di, tgs.TGS_buffer ; es:di -> string buffer mov al, '{' stosb ; send out the color call EmitTextColor ; do underline and strikethru call EmitUnderlineStrikethru ; do any local motions for sub/superscript if necc. call EmitLocalMotion ; done with attributes, close brace mov al, '}' stosb mov al, C_CR mov ah, C_LF stosw call EmitBuffer .leave ret EmitTextAttr endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitLocalMotion %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Calculate the amount of up/down we need to shift for subscript/superscript CALLED BY: GLOBAL PASS: es:di - where to write PostScript code RETURN: es:di - adjusted to point after anything written DESTROYED: ax,bx PSEUDO CODE/STRATEGY: get font metrics info, do a few math operations KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 05/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitLocalMotion proc near uses cx, dx, ds, si tgs local TGSLocals .enter inherit ; need to do a little local motion to account for super and ; subscript. TGS_newstyle has the style bits left over from ; the last style run, so we can use that to determine if the ; previous style run was moved (since we have to move it back). ; Then we look at the new style bits and apply another local ; motion to deal with possible super/subscript. Actually, we ; combine these motions and use one "rmoveto". If the current ; style is sub or superscript, then we have to double the ; movement. mov dx, tgs.TGS_locmot.WWF_int ; get prev local motion mov cx, tgs.TGS_locmot.WWF_frac mov tgs.TGS_locmot.WWF_int, 0 mov tgs.TGS_locmot.WWF_frac, 0 neg cx ; negate, since we're fixing not dx ; the previous motion cmc adc dx, 0 push di GetPathOrDrawGState di ; get right handle call GrGetTextStyle pop di and al, mask TS_SUPERSCRIPT or mask TS_SUBSCRIPT pushf ; save zero flag status jz setMotion ; set it up push cx, dx, si, di mov si, GFMI_HEIGHT ; we want the height GetPathOrDrawGState di ; get right handle call GrFontMetrics test al, mask TS_SUPERSCRIPT ; check which mov al, 0 ; dx.ax = height mov cx, ax ; dx.cx = height mov bx, SUPERSCRIPT_OFFSET_INT ; assume superscript mov ax, SUPERSCRIPT_OFFSET_FRAC jnz applyTrans ; no, do subscript mov bx, SUBSCRIPT_OFFSET_INT mov ax, SUBSCRIPT_OFFSET_FRAC applyTrans: call GrMulWWFixed ; dx.cx = trans amt mov bx, dx ; bx.ax = y trans mov ax, cx pop cx, dx, si, di mov tgs.TGS_locmot.WWF_int, bx ; save for next style run mov tgs.TGS_locmot.WWF_frac, ax add cx, ax ; add in to previous motion adc dx, bx ; have the motion amount. Write it out if non-zero. setMotion: popf ; restore zero flag, to see if jz haveAmount ; we need to mul * 2 mov bx, SCRIPT_FACTOR_INT ; div by appropriate amount mov ax, SCRIPT_FACTOR_FRAC ; call GrSDivWWFixed ; divide by fraction... haveAmount: mov ax, dx ; check for zero or ax, cx jz done ; write out "0 <motion> rmoveto" mov al, ' ' ; put in space separator stosb mov ax, cx mov bx, dx ; copy number down to bx.ax call WWFixedToAscii ; convert y motion to ascii mov bx, handle PSCode call MemLock mov ds, ax mov si, offset emitSSM ; invoke local motion proc mov cx, length emitSSM rep movsb call MemUnlock done: .leave ret EmitLocalMotion endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitTextColor %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Write out text color CALLED BY: INTERNAL EmitTextAttr, EmitTabLeader PASS: tgs - local stack frame es:di - buffer where to write it RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: just get/set the color KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 04/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitTextColor proc near uses ax, cx, dx, bx, ds, si tgs local TGSLocals .enter inherit ; send out the color push di GetPathOrDrawGState di ; get right handle call GrGetTextColor pop di ; RGB values need to be tweaked to get them to match what is ; on-screen... call MapRGBForPrinter ; save G and B for now mov dx, bx mov bl, al ; set up as int clr bh call UWordToAscii ; write R mov al, ' ' stosb mov bl, dl clr bh call UWordToAscii ; write G mov al, ' ' stosb mov bl, dh clr bh call UWordToAscii ; write B mov bx, handle PSCode ; lock PSCode resource call MemLock mov ds, ax mov si, offset emitSC mov cx, length emitSC rep movsb call MemUnlock .leave ret EmitTextColor endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitUnderlineStrikethru %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Calculate the amount of up/down we need to shift for subscript/superscript CALLED BY: GLOBAL PASS: es:di - where to write PostScript code ds:dx - pointer to string cx - #characters RETURN: es:di - adjusted to point after anything written DESTROYED: ax,bx PSEUDO CODE/STRATEGY: get font metrics info, do a few math operations for underline and strikethru, we need the line thickness, the line position (y offset), and the length. underline pos offset is gotten from GrFontMetrics strikethru pos is 3/5ths the way up from the baseline to the xheight (mean height). note: there is a problem if a local motion was done on the last style run. that's why we grab the previous local motion amount and adjust our position based on that. KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 05/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ STRIKETHRU_FACTOR_FRAC equ 0x3333 STRIKETHRU_FACTOR_INT equ 0xffff EmitUnderlineStrikethru proc near uses cx, dx, ds, si tgs local TGSLocals .enter inherit push di ; get current style bits mov di, tgs.TGS_gstate ; calc the style run length mov si, dx ; ds:si -> string call GrTextWidthWBFixed ; dx.ah - width of style run clr al mov tgs.TGS_runlen.WWF_frac, ax mov tgs.TGS_runlen.WWF_int, dx ; grab the current style bits call GrGetTextStyle pop di test al, mask TS_UNDERLINE LONG jz checkStrikeThru push ax ; NOTE: since in GEOS the baseline position is messed with ; in superscript mode, we need to cancel that mode to get the ; true baseline position for the font. Hopefully there will ; be a better way to do this soon, but for new we need to ; push the GState, reset the superscript bit, then read the ; baseline information... test al, mask TS_SUPERSCRIPT or mask TS_SUBSCRIPT jz notSuperOrSub push di ; save offset mov di, tgs.TGS_gstate call GrSaveState mov ah, al and ah, mask TS_SUPERSCRIPT or mask TS_SUBSCRIPT and al, not (mask TS_SUPERSCRIPT or mask TS_SUBSCRIPT) call GrSetTextStyle pop di notSuperOrSub: push di mov di, tgs.TGS_gstate mov si, GFMI_UNDER_POS call GrFontMetrics mov bx, dx mov cx, ax ; bx.cx = underline pos clr cl mov si, GFMI_BASELINE call GrFontMetrics ; dx.ah = baseline pos clr al sub cx, ax ; underline offset - baseline sbb bx, dx mov si, GFMI_UNDER_THICKNESS ; plus 1/2 line thickness call GrFontMetrics clr al push bx, cx ; save net result mov cx, ax ; dx.cx = thickness dec dx jns divUnderThick clr dx divUnderThick: mov bx, 2 clr ax call GrSDivWWFixed ; calc thickness/2 pop bx, ax ; restore result add cx, ax adc dx, bx mov bx, tgs.TGS_locmot.WWF_int ; get prev local motion mov ax, tgs.TGS_locmot.WWF_frac neg ax not bx cmc adc bx, 0 add cx, ax adc dx, bx pop di call EmitStyleLine pop ax ; restore style byts ; this is part two of the screwyness that we initiated above. ; this code just restores the gstate to what it was. test al, mask TS_SUPERSCRIPT or mask TS_SUBSCRIPT jz checkStrikeThru push di ; save offset mov di, tgs.TGS_gstate call GrRestoreState pop di checkStrikeThru: test al, mask TS_STRIKE_THRU jz done push di mov di, tgs.TGS_gstate mov si, GFMI_MEAN call GrFontMetrics mov cx, ax clr cl mov ax, STRIKETHRU_FACTOR_FRAC mov bx, STRIKETHRU_FACTOR_INT call GrMulWWFixed push dx, cx mov si, GFMI_UNDER_THICKNESS ; plus 1/2 line thickness call GrFontMetrics clr al mov cx, ax ; dx.cx = thickness dec dx jns divStrikeThick clr dx divStrikeThick: mov bx, 2 clr ax call GrSDivWWFixed ; calc thickness/2 pop bx, ax ; restore result pop di add cx, ax adc dx, bx mov bx, tgs.TGS_locmot.WWF_int ; get prev local motion mov ax, tgs.TGS_locmot.WWF_frac neg ax not bx cmc adc bx, 0 add cx, ax adc dx, bx call EmitStyleLine done: .leave ret EmitUnderlineStrikethru endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitStyleLine %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Write out a string CALLED BY: GLOBAL PASS: dx.cx - offset to draw line RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: grabs the current underline width and calculate the length of the current style run and uses the passed offset. KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 05/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitStyleLine proc near uses cx, dx, ds, si tgs local TGSLocals .enter inherit ; save y offset for later... push cx, dx mov al, ' ' ; prepend space char stosb ; first we need to write out the line length. This is the ; length of this style run...it was calc'd up above and stored ; in tgs... mov bx, tgs.TGS_runlen.WWF_int ; get run length mov ax, tgs.TGS_runlen.WWF_frac call WWFixedToAscii ; write out the length mov al, ' ' ; append space char stosb pop ax, bx call WWFixedToAscii ; write out the offset mov al, ' ' ; append space char stosb ; call FontMetrics routine to get the thickness push di mov di, tgs.TGS_gstate mov si, GFMI_UNDER_THICKNESS ; get line thickness call GrFontMetrics pop di clr al mov bx, dx dec bx ; fudge it to work jns writeThickness clr bx writeThickness: call WWFixedToAscii ; write out thickness ; write out DrawUnderLine proc name mov bx, handle PSCode ; lock down resource call MemLock mov ds, ax ; ds -> resource mov si, offset emitDUL mov cx, length emitDUL rep movsb call MemUnlock ; release resource .leave ret EmitStyleLine endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitFont %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Write out the proper PC/GEOS altered font name CALLED BY: GLOBAL PASS: see HandleStyleRun RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: The initial mapping is done by an earlier routine for each page. This routine merely looks up the right ID and emits the right code. KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 04/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitFont proc near uses ax, cx, dx, bx, ds, si, es tgs local TGSLocals .enter inherit ; we want to emit the PostScript name, prepended by an ; underscore. We need both the FontID and the style word, ; since if we have Roman italic, for example, we want to ; map it to Times-Italic font in PostScript (as opposed to ; mapping it to Times-Roman and obliquing it). push di ; save pointer into buffer GetPathOrDrawGState di ; get right handle call GrGetFont ; get the current fontID call GrGetTextStyle ; get style byte pop di ; restore buffer pointer mov dl, al ; save style bits ; cx=fontID, al = style bits. Find the right entry. mov bx, tgs.TGS_pageFonts.handle ; get block handle call MemLock ; lock block mov ds, ax ; ds -> block mov al, dl ; restore style bits ; if the mapping fails, we come back here for try #2 tryAgain: mov si, tgs.TGS_pageFonts.chunk ; get chunk handle mov si, ds:[si] ; dereference chunk handle mov dx, cx ; dx = desired font id mov cx, ds:[si].PF_count ; get entry count add si, offset PF_first ; point at first entry entryLoop: add si, size PageFont ; bump past scratch space cmp dx, ds:[si].PF_id ; id match ? jne nextEntry cmp al, ds:[si].PF_style ; style match ? je foundMatch nextEntry: loop entryLoop ; fell off the end. This probably means that we're trying ; to map the font to symbol. If that is the case, then handle ; that as a special case. Otherwise, spew warning. cmp dx, FID_PS_SYMBOL ; is it symbol font ? EC < WARNING_NE PS_MAPPING_UNRECOGNIZED_FONT_TO_HELVETICA > je mappingOK ; if we really want it, do it mov cx, FID_PS_HELVETICA ; change what we want to some jmp tryAgain ; thing nicer to look mappingOK: segmov ds, cs, si mov si, offset symbolFont jmp foundCommon ; ds:si points at the right PageFont entry. We need to copy ; over the name, followed by a "true" or "false" which ; indicates whether or not to re-encode. foundMatch: mov al, ds:[si].PF_newstyle ; get new style bits foundCommon: mov ah, ds:[si].PF_flags ; get re-encode flag for later mov cl, ds:[si].PF_nlen ; get length of name clr ch mov tgs.TGS_newstyle, al ; set them for later add si, offset PF_name ; ds:si -> name rep movsb ; copy name over mov al, ' ' stosb segmov ds, cs, si mov si, offset emitTrue mov cx, length emitTrue test ah, mask PFF_REENCODE ; if standard, need to fix jnz copyBoolean mov si, offset emitFalse mov cx, length emitFalse copyBoolean: rep movsb mov bx, tgs.TGS_pageFonts.handle ; get block handle call MemUnlock .leave ret EmitFont endp emitTrue char " true " emitFalse char " false " symbolFont PageFont < FID_PS_SYMBOL, 0, 0, 0, 7, \ <0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\ 0,0,0,0,0,0,0>,\ <"/Symbol78901234567890123456789012345678901234567890123456789">> COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CheckAutoHyphen %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Check to see if we need to put a hyphen at the end CALLED BY: INTERNAL EmitTextField PASS: ds:bx - pointer to TextField element (base of current chunk) ds:dx - pointer to text string (within ds:bx) ds:bx.si - pointer to TFStyleRun cx - character count RETURN: cx - real char count ds:bx - fixed up ds:dx - pointer to text string DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CheckAutoHyphen proc near tgs local TGSLocals .enter inherit ; check for auto one test ds:[bx].ODTF_saved.GDFS_flags, \ mask HF_AUTO_HYPHEN jz done ; have an auto-hyphen. allocate a new chunk and copy over the ; string. sub dx, bx ; convert back to offset push cx, ax, es, di, si ; save source reg ; figure which gstring chunk is being employed to hold the ; element so we can deref it after the realloc mov si, tgs.TGS_pathchunk cmp bx, ds:[si] ; path chunk? je haveSrcChunk ; yes mov si, tgs.TGS_chunk.chunk ; no, must be main one haveSrcChunk: mov ax, tgs.TGS_xtrachunk ; use extra chunk add cx, 2 ; add some space call LMemReAlloc mov bx, ds:[si] ; deref src chunk segmov es, ds ; es -> string mov di, ax mov di, ds:[di] ; get pointer to chunk mov si, dx ; ds:si -> string add si, bx mov dx, di ; set pointer there too sub cx, 2 ; copy this many rep movsb mov al, '-' stosb ; store final hypen pop cx, ax, es, di, si inc cx ; really is one more done: .leave ret CheckAutoHyphen endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitText %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Handle a GR_DRAW_TEXT or GR_DRAW_TEXT_CP element or GR_DRAW_CHAR or GR_DRAW_CHAR_CP CALLED BY: EXTERNAL TransGString PASS: es - points to locked options block si - gstring handle RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: extract the element and draw it. KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 04/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitText proc far uses ax, bx, cx, si, di, ds tgs local TGSLocals .enter inherit call ExtractElement ; get the element into a buffer call EmitTextCommon ; all done, just leave mov bx, tgs.TGS_chunk.handle call MemUnlock .leave ret EmitText endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitTextCommon %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Write out a string CALLED BY: GLOBAL PASS: nothing RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: put pseudo code here KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitTextCommon proc far uses ax, bx, cx, dx, si, di, ds tgs local TGSLocals .enter inherit mov dl, ds:[si].ODT_opcode ; see if CP cmp dl, GR_DRAW_TEXT ; see if CP jne getCP mov ax, ds:[si].ODT_x1 mov bx, ds:[si].ODT_y1 mov cx, ds:[si].ODT_len add si, size OpDrawText ; have all we need. Output the piece of text. outputText: mov tgs.TGS_locmot.WWF_int, 0 ; init local motion mov tgs.TGS_locmot.WWF_frac, 0 call EmitDrawText .leave ret ; CP version. Get what we need getCP: GetPathOrDrawGState di ; get right handle call GrGetCurPos cmp dl, GR_DRAW_TEXT_CP ; see if CP jne getChar mov cx, ds:[si].ODTCP_len add si, size OpDrawTextAtCP jmp outputText ; GR_DRAW_CHAR or GR_DRAW_CHAR_CP getChar: mov cx, 1 cmp dl, GR_DRAW_CHAR_CP jne getCharPos add si, offset ODCCP_char jmp outputText getCharPos: mov ax, ds:[si].ODC_x1 mov bx, ds:[si].ODC_x1 add si, offset ODC_char jmp outputText EmitTextCommon endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitDrawText %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Write out some text CALLED BY: INTERNAL EmitText PASS: es - locked options block ds:si - pointer to string cx - #characters ax - x position bx - y position RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: emit PS code to draw text KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 04/91 Initial version VL 06/95 preserve handle of ds %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitDrawText proc near uses ax, bx, cx, dx, ds, es, si, di tgs local TGSLocals .enter inherit ; we need to output all that stuff to start an object, output ; the transform, etc, etc. push bx ; save y pos push ax ; save x pos push es:[PSEO_fonts] ; save fonts list enum push ds:[LMBH_handle] mov bx, (GR_DRAW_TEXT - GSE_FIRST_OUTPUT_OPCODE)*2 call EmitStartObject call EmitTransform ; now we need to emit the opening bracket for the array of ; style run arrays. (Even thought we're only writing one) push cx mov bx, handle PSCode call MemLock mov ds, ax ; ds -> PSCode resource mov bx, tgs.TGS_stream EmitPS emitOpenBracket mov bx, handle PSCode call MemUnlock pop cx pop bx call MemDerefDS ; write out the string and attributes mov dx, si call EmitTextString call EmitTextAttr ; see if kerning is on. If not, write out zero for kerning. push cx GetPathOrDrawGState di ; get right handle call GrGetFont ; dxah = point size rndwbf dxah ; dx = integer size call GrGetTrackKern ; ax = degree of track kerning pop cx ; limit to values from graphics.def. This code stolen from ; the kernel calculation for kerning. cmp ax, MAX_TRACK_KERNING jle maxOK ;branch if too large mov ax, MAX_TRACK_KERNING maxOK: cmp ax, MIN_TRACK_KERNING jge minOK ;branch if too small mov ax, MIN_TRACK_KERNING minOK: imul dx ;ax <- ptsize * degree jc isBig ;branch if too large tst ax jns haveKern ;no branch if negative tst ds:GS_trackKernDegree ;test original sign js haveKern ;branch if orig neg isBig: tst ds:GS_trackKernDegree ;test original sign js isBigNegative ;branch if negative mov ax, MAX_KERN_VALUE ;ax <- max kern value jmp haveKern isBigNegative: mov ax, MIN_KERN_VALUE ;ax <- min kern value haveKern: mov bx, ax clr ax ; bxax = degree of kerning segmov es, ss, di lea di, tgs.TGS_buffer ; es:di -> string buffer call WWFixedToAscii mov al, ' ' ; put in the separator stosb ; write out the font pop bx call EmitFont ; write style matrix and font ; write out point size push di, cx ; save pointer GetPathOrDrawGState di ; get right handle call GrGetFont pop di, cx mov bx, dx clr al call WWFixedToAscii ; output style matrix for styles not covered by font selection mov al, tgs.TGS_newstyle call EmitStyleMatrix ; output the closing brackets push ds, si, cx mov bx, handle PSCode call MemLock mov ds, ax mov si, offset emitCloseBrackets mov cx, length emitCloseBrackets rep movsb mov bx, handle PSCode call MemUnlock pop ds, si, cx push di GetPathOrDrawGState di ; get right handle call GrGetTextSpacePad pop di mov bx, dx ; restore space padding mov ah, bl clr al call WWFixedToAscii ; convert to ascii mov al, ' ' ; space delimit things stosb ; calc and write out width push di GetPathOrDrawGState di ; get right handle call GrTextWidthWBFixed push ax,cx,dx mov ch, ah clr cl clr ax,bx call GrRelMoveTo ; update current position pop ax,cx,dx pop di mov bx, dx ; write out width clr al call WWFixedToAscii ; convert to ascii mov al, ' ' stosb ; write out x pos pop bx ; restore x pos clr ax tst tgs.TGS_xfactor ; see if OK jnz xOK clr bx xOK: call WWFixedToAscii mov al, ' ' stosb ; write out y pos. This depends on what the passed value ; means. Get the mode to see... pop bx ; restore ypos push di GetPathOrDrawGState di ; get right handle call GrGetTextMode pop di test al, mask TM_DRAW_BASE ; assume drawing at baseline jz getBaseline ; no, compute baseline pos clr ax haveBaseline: tst tgs.TGS_yfactor ; see if OK jnz yOK clr bx clr ax yOK: call WWFixedToAscii ; write Y POS mov bx, handle PSCode call MemLock mov ds, ax mov si, offset emitDSG mov cx, length emitDSG rep movsb call EmitBuffer ; write it all out mov bx, handle PSCode call MemUnlock call EmitEndObject .leave ret ; not drawing at baseline. Compute where baseline is. ; in each case, we have to subtract the baseline position, ; so get that first and adjust it. getBaseline: push di, cx, dx ; save pointer GetPathOrDrawGState di ; get right handle mov si, GFMI_BASELINE ; get baseline offset call GrFontMetrics ; get baseline offset mov ch, ah ; cx will hold fraction clr cl add bx, dx mov ah, GFMI_HEIGHT ; assume drawing from bottom test al, mask TM_DRAW_BOTTOM ; drawing at bottom ? jnz notTop mov ah, GFMI_ACCENT ; assume drawing from accent test al, mask TM_DRAW_ACCENT ; drawing at ACCENT height ? jz doneCalc notTop: mov al, ah ; get enum into al call GrFontMetrics ; get value sub ch, ah ; do fraction sbb bx, dx ; do integer part ; not any of these -- drawing at the top of the character box ; that means we're done... doneCalc: mov ax, cx pop di, cx, dx jmp haveBaseline EmitDrawText endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitStyleMatrix %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Write out a transformation matrix for style bits that we have to do ourselves CALLED BY: INTERNAL EmitDrawText, HandleStyleRun PASS: al - style bits to emulate es:di - where to put matrix RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: put pseudo code here KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitStyleMatrix proc near uses ds, si, cx tgs local TGSLocals .enter inherit ; build up the matrix in the gstate, then output it. But ; save the current stuff first push di GetPathOrDrawGState di ; get right handle call GrSaveState call GrSetNullTransform ; set it up call AddMetricsStyles ; add in the style-related tm ; read in the matrix to a buffer and emit it segmov ds, ss, si lea si, tgs.TGS_matrix call GrGetTransform ; get matrix pop di mov al, ' ' stosb call MatrixToAscii ; write it out mov al, ' ' stosb ; restore the state of things push di GetPathOrDrawGState di ; get right handle call GrRestoreState pop di .leave ret EmitStyleMatrix endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AddMetricsStyles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Add scales, et al to the transformation matrix for styles CALLED BY: SetupTMatrix() PASS: di - gstate handle al - styles to implement (TextStyle) RETURN: tmatrix in gstate has all scaling/rotation DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 10/17/90 Initial version jim 4/91 converted from nimbus driver %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SCRIPT_FACTOR_INT = 0 SCRIPT_FACTOR_FRAC = 0x8000 ;superscript,subscript = 1/2 SUBSCRIPT_OFFSET_INT = 0x0 SUBSCRIPT_OFFSET_FRAC = 0x1a00 ;offset below SUPERSCRIPT_OFFSET_INT = 0xffff SUPERSCRIPT_OFFSET_FRAC = 0x9fff ;offset above BOLD_FACTOR_INT = 0x0001 BOLD_FACTOR_FRAC = 0x2000 ;bold = 1.10 ITALIC_FACTOR_INT = 0xffff ITALIC_FACTOR_FRAC = 0xc996 ;italic = tan(-12) TRANSFORM_STYLES = mask TS_SUPERSCRIPT or \ mask TS_SUBSCRIPT or \ mask TS_ITALIC or \ mask TS_BOLD AddMetricsStyles proc near uses ax, bx, cx, dx, ds .enter ; first check out width and weight push ax clr ax call GrGetFontWidth cmp al, FWI_MEDIUM ; see if normal je checkWeight clr ah ; it's UNSIGNED, wacko mov dx, ax mov bx, FWI_MEDIUM clr ax, cx call GrUDivWWFixed mov bx, 1 clr ax call GrApplyScale checkWeight: call GrGetFontWeight cmp al, FW_NORMAL je checkStyles clr ah mov dx, ax mov bx, FW_NORMAL clr ax, cx call GrUDivWWFixed ; dxcx = x factor mov bx, 1 clr ax call GrApplyScale ; Any styles of interest? checkStyles: pop ax test al, TRANSFORM_STYLES ;any to styles to implement? jz done ;branch if no styles ; If faking bold, scale horizontally test al, mask TS_BOLD ;bold? jz noBold push ax ; save style bits mov dx, BOLD_FACTOR_INT mov cx, BOLD_FACTOR_FRAC ;dx.cx <- scale factor mov bx, 1 clr ax call GrApplyScale pop ax ; restore style bits ; If doing sub- or superscript, scale both directions. And ; adjust the drawing position. noBold: test al, mask TS_SUBSCRIPT or mask TS_SUPERSCRIPT jz noScript push ax ; save style bites mov dx, SCRIPT_FACTOR_INT mov cx, SCRIPT_FACTOR_FRAC ;dx.cx <- scale factor mov bx, SCRIPT_FACTOR_INT mov ax, SCRIPT_FACTOR_FRAC ;dx.cx <- scale factor call GrApplyScale pop ax ; restore style bites ; If doing italic, use a skew factor noScript: test al, mask TS_ITALIC ;italic? jz done push ax mov bx, di ; lock down gstate call MemLock push bx mov ds, ax mov dx, ds:[GS_TMatrix].TM_22.WWF_int ; copy value mov cx, ds:[GS_TMatrix].TM_22.WWF_frac mov bx, ITALIC_FACTOR_INT mov ax, ITALIC_FACTOR_FRAC ;dx.cx <- scale factor call GrMulWWFixed mov ds:[GS_TMatrix].TM_21.WWF_int, dx mov ds:[GS_TMatrix].TM_21.WWF_frac, cx pop bx call MemUnlock pop ax ; restore style buits done: .leave ret AddMetricsStyles endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetPageFonts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Scan a graphics string and extract all the font info, including which PostScript font we will use (or download) CALLED BY: INTERNAL TranslateGStringCommon PASS: tgs - passed stack frame with all the crucial info RETURN: pageFonts chunk filled with page font info. DESTROYED: nothing PSEUDO CODE/STRATEGY: scan string until we reach a new page or the end of the string. for each text element found, record the font info, including how it maps to the PostScript font set. KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 06/91 Initial version Jim 1/93 Updated to use 2.0 GString routines %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetPageFonts proc far uses ax, bx, cx, dx, si, di, es, ds tgs local TGSLocals .enter inherit ; before we start, initialize the page fonts with FID_PS_HELV, ; since if we don't find the font, we'll use that. push bx mov bx, tgs.TGS_pageFonts.handle push bx call MemLock ; ax -> block mov es, ax ; es -> pagefonts block mov cx, FID_PS_HELVETICA ; map to helv. clr al ; no style bits call GetPageFontEntry pop bx ; restore block handle call MemUnlock ; unlock the block pop bx mov si, tgs.TGS_gstring ; get gstring handle clr di ; need gstate too call GrCreateState ; di = GState handle ; now we're going to scan through all the elements of the ; string, looking for text elements keepLooking: mov dx, mask GSC_NEW_PAGE or mask GSC_OUTPUT call GrDrawGStringAtCP mov ax, dx ; ax = GSRetType ; check why we stopped. If we're done, then we're done with ; our font scanning. Else check for text-type elements and ; do the right thing :) cmp ax, GSRT_FAULT ; if some problem je donePage ; ...then exit cmp ax, GSRT_COMPLETE ; else if done je donePage ; ...then done cmp ax, GSRT_NEW_PAGE ; else if end page je donePage ; ...then done ; there are just a few text calls we need to support... checkOpcode: cmp cl, GR_END_GSTRING ; if end of string... je donePage cmp cl, GR_NEW_PAGE ; if end of string... je donePage cmp cl, GR_DRAW_TEXT_FIELD ; most common... je handleTextField cmp cl, GR_DRAW_TEXT ; next common... je handleText cmp cl, GR_DRAW_TEXT_CP ; next common... jne keepLooking handleText: call ExtractDrawTextFont jmp checkNext handleTextField: call ExtractTextFieldFonts ; before we go on, check out the next opcode. Most likely ; it's not something we're interested in, but you never know. checkNext: cmp cx, GSRT_COMPLETE ; if done... je donePage clr cx ; just teasing call GrGetGStringElement ; just want opcode mov cl, al jmp checkOpcode ; done with scan. Free the GState and GString structures that ; we allocated above donePage: ; since we created a new gstring handle above, get rid of ; it now. call GrDestroyState ; don't need anymore ; reset the file back to where it was. mov al, GSSPT_BEGINNING ; set position to begin call GrSetGStringPos .leave ret GetPageFonts endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ExtractTextFieldFonts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Grab text font info out of GrDrawTextField element CALLED BY: INTERNAL GetPageFonts PASS: si - handle graphics string di - handle gstate RETURN: cx - GSRetType from call to GrCopyGString. should be GSRT_ONE, but could be GSRT_COMPLETE. DESTROYED: nothing PSEUDO CODE/STRATEGY: yuck, dealing with embedded graphics one more time KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 06/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ExtractTextFieldFonts proc near uses ax, bx, dx, di, si, es tgs local TGSLocals .enter inherit call ExtractTextElement push cx ; save return type mov di, tgs.TGS_gstate ; di = gstate handle ; get the size of the string mov bx, si ; ds:bx -> element mov cx, ds:[bx].ODTF_saved.GDFS_nChars ; text string size ; set up ds:si to point at style runs mov si, size OpDrawTextField ; bx.si -> string ; alright, we're ready to go. The following pointers are set: ; ds:bx -> pointer to a OpDrawTextField structure ; ds:bx.si -> pointer to first TFStyleRun structure ; cx - # characters in the line ; loop through the style runs, getting out the attributes call ExtractStyleGroupFonts ; handle next group of runs ; all done, just leave mov bx, tgs.TGS_chunk.handle ; unlock block call MemUnlock ; release string block pop cx ; restore return type .leave ret ExtractTextFieldFonts endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ExtractTextElement %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Copy a gstring object from the current gstring to a separate buffer. CALLED BY: INTERNAL Most of the EmitXXX routines call this. PASS: si - gstring handle inherits TGSLocals structure RETURN: ds:si - points to data cx - GSRetType from call to GrCopyGString. should be GSRT_ONE, but could be GSRT_COMPLETE. DESTROYED: nothing PSEUDO CODE/STRATEGY: caller is repsonsible for making sure the GState is updated with the new current position KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 02/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ExtractTextElement proc far uses ax, bx, dx, di tgs local TGSLocals .enter inherit ; lock down our scratch block, clear out the scratch chunk mov bx, tgs.TGS_chunk.handle call MemLock ; mov ds, ax ; ds -> block clr cx ; resize to zero mov ax, tgs.TGS_chunk.chunk ; ax = chunk handle call LMemFree call MemUnlock ; first set up to draw into our buffer push si ; save source GString handle mov cl, GST_CHUNK ; it's a memory type gstring call GrCreateGString ; di = gstring handle mov tgs.TGS_chunk.chunk, si ; store new chunk pop si ; restore source gstring ; now draw the one element into our buffer mov dx, mask GSC_ONE ; return after one element call GrCopyGString push dx ; save return type ; that's all we need, so biff the string mov dl, GSKT_LEAVE_DATA ; don't kill the data mov si, di ; si = GString handle clr di ; di = GState handle (0) call GrDestroyGString ; set up a pointer to the data mov bx, tgs.TGS_chunk.handle call MemLock ; mov ds, ax mov si, tgs.TGS_chunk.chunk ; restore chunk handle mov si, ds:[si] ; ds:si -> data pop cx ; restore return type .leave ret ExtractTextElement endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ExtractStyleGroupFonts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Traverse a style group and extract the font info CALLED BY: INTERNAL ExtractTextFieldFonts PASS: ds:bx -> pointer to a OpDrawTextField structure ds:bx.si -> pointer to first TFStyleRun structure cx - # characters in the line, including a count of one for each embedded graphic. RETURN: ds -> still points to block, may have changed cx - updated to #chars left to bdo other pointers updated appropriately DESTROYED: es PSEUDO CODE/STRATEGY: just loop through all the style runs KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 06/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ExtractStyleGroupFonts proc near uses ax, bx, di tgs local TGSLocals .enter inherit ; while there are still characters left and we haven't hit ; one of those fucking embedded graphics, keep outputting the ; style run arrays. styleRunLoop: push cx ; save #chars left (total) mov cx, ds:[bx][si].TFSR_count ; get character count ; we want to skip over single tab characters. Check for ; a one-character run, then check to see if is a tab. cmp cx, 1 ; one character ? jne getFonts ; no, continue xchg si, dx ; save a reg, cmp {byte} ds:[bx][si], C_TAB ; is it a tab ? xchg si, dx je doneRun ; no, continue getFonts: push cx segmov es, ds, cx ; es -> FontEntry block add si, bx ; ds:si -> TFStyleRun add si, TFSR_attr ; point to attributes mov cx, ds:[si].TA_font ; get font and style info mov al, ds:[si].TA_styleSet ; get style bits sub si, TFSR_attr sub si, bx ; things back to normal call GetPageFontEntry ; map it baby segmov ds, es, cx ; blk may have moved pop cx mov bx, tgs.TGS_chunk.chunk ; dereference again mov bx, ds:[bx] ; check to see if the font will be downloaded. If so, check ; which chars to download. Assume hyphen since we skipped ; checking to see if we needed it. test es:[di].PF_flags, mask PFF_DOWNLOAD ; download font ? jz doneRun ; we're going to download the font. optimize things by ; checking which characters to download. Check the string. ; cx = #chars in this run push cx, bx, si add si, bx ; ds:si -> StyleRun add si, size TFStyleRun ; ds:si -> string clr bh charLoop: lodsb ; get next char mov bl, al and bl, 7 ; bit index mov ah, cs:bitMasks[bx] ; ah = bit mask mov bl, al shr bx, 1 shr bx, 1 shr bx, 1 or es:[di].PF_map[bx], ah ; twiddle the right bit loop charLoop mov bl, C_HYPHEN and 7 ; do hyphen too mov ah, cs:bitMasks[bx] ; ah = bit mask mov bl, C_HYPHEN shr 3 or es:[di].PF_map[bx], ah ; twiddle the right bit pop cx, bx, si doneRun: mov di, cx ; restore #chars in this run pop cx ; restore #characters total sub cx, di ; calc #chars left add si, size TFStyleRun ; bump to next style run add si, di ; bump over string too tst cx ; ...might be done jnz styleRunLoop ; ...but maybe not .leave ret ExtractStyleGroupFonts endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ExtractDrawTextFont %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Write out a string CALLED BY: INTERNAL GetPageFonts PASS: di - handle graphics string cl - element opcode (either DRAW_TEXT or DRAW_TEXT_CP) RETURN: cx - GSRetType from call to GrCopyGString. should be GSRT_ONE, but could be GSRT_COMPLETE. DESTROYED: nothing PSEUDO CODE/STRATEGY: stopped on a DRAW_TEXT element KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 06/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ExtractDrawTextFont proc near uses ax, bx, dx, si, di, ds, es tgs local TGSLocals .enter inherit ; get the current info push cx ; save opcode call ExtractTextElement ; ds:si -> element push cx ; save GSRetType call GrGetFont ; cx = FontID call GrGetTextStyle ; al = style bits segmov es, ds, dx ; es -> block call GetPageFontEntry ; es:di -> entry segmov ds, es, ax ; ds may have moved ; if we're not mapping to a PostScript font, then do a scan ; of the characters pop cx ; restore GSRetType pop dx ; restore opcode push cx ; save GSRetType again test es:[di].PF_flags, mask PFF_DOWNLOAD ; download font ? jz done ; we're going to download the font. optimize things by ; checking which characters to download. Check the string. clr bh add si, offset ODT_len ; to get at string length cmp dl, GR_DRAW_TEXT ; check assumption je scanChars add si, offset ODTCP_len - offset ODT_len scanChars: mov cx, ds:[si] ; cx = string length add si, 2 ; ds:si -> string charLoop: lodsb ; get next char mov bl, al and bl, 7 ; bit index mov ah, cs:bitMasks[bx] ; ah = bit mask mov bl, al shr bx, 1 shr bx, 1 shr bx, 1 or es:[di].PF_map[bx], ah ; twiddle the right bit loop charLoop done: mov bx, tgs.TGS_chunk.handle ; unlock block call MemUnlock ; release string block pop cx ; restore GSRetType .leave ret ExtractDrawTextFont endp bitMasks byte 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetPageFontEntry %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get current font info and write it out to our PageFonts struct CALLED BY: INTERNAL GetPageFonts PASS: cx - desired FontID al - desired style bits es - locked block with PageFonts array RETURN: es:di - pointer into PageFont array at correct entry (es may have moved) DESTROYED: nothing PSEUDO CODE/STRATEGY: get current font from GState try to map to PostScript font fill out a new PageFont struct, if needed if (mapping not successful) scan string and determine what chars are needed. KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 06/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetPageFontEntry proc near uses ax, bx, cx, dx, si, ds tgs local TGSLocals .enter inherit ; lock down the PageFonts array and store this info away. ; Init the rest of the scratch block mov di, tgs.TGS_pageFonts.chunk ; get chunk handle mov di, es:[di] ; dereference chunk handle add di, offset PF_first ; point to scratch structure mov es:[di].PF_id, cx ; store ID and style info mov es:[di].PF_style, al mov es:[di].PF_flags, 0 ; init the flags ; if the font is a bitmap font, them just map it to Times-Roman ; app has no business using one of those anyway cmp cx, FM_PRINTER ; upper end bitmap fonts jae changeToRoman cmp cx, FM_NIMBUSQ ; first outline ID jae checkPS changeToRoman: mov cx, FID_PS_TIMES_ROMAN ; set to Roman ; now try to map it to PostScript checkPS: call MapFontToPostScript ; dh = "closeness" ; if the font isn't a perfect match, then we should download it cmp dh, FM_EXACT ; if exact, we're done je havePageFont ; also check to see if that font is available. If not, then ; use the PostScript mapping. mov cx, es:[di].PF_id ; get font id mov dl, mask FEF_OUTLINES ; match fontID call GrCheckFontAvail cmp cx, FID_INVALID ; if not, take what PS gave je havePageFont ; us ; We didn't get an exact match, so use a download font. ; set the right flags and change the name to something unique ; also, don't have to re-encode, so reset that flag. and es:[di].PF_flags, not mask PFF_REENCODE or es:[di].PF_flags, mask PFF_DOWNLOAD ; map the font id and style combinations to see how far the ; font driver will go for us... ; For 2.0, we want to try to map better for styles. For ; 1.2, we're going to punt and do all the style in PostScript mov cx, es:[di].PF_id ; get font id mov dl, es:[di].PF_style ; tack on style bits mov es:[di].PF_newstyle, dl ; store leftovers mov es:[di].PF_nlen, 8 ; #chars in new name mov si, di ; save pointer to entry add di, offset PF_name ; point to the name field mov al, '/' ; start it with an X mov ah, 'X' ; start it with an X stosw mov al, ch call ByteToHexAscii ; creates a name "/X1234" mov al, cl ; or something like that call ByteToHexAscii mov al, dl call ByteToHexAscii ; tack on style bits mov di, si ; restore pointer to entry ; and another thing. clear out the bits that tell us which ; characters to download clr ax add di, offset PF_map mov cx, 16 ; 32 bytes to clear rep stosw mov di, si ; recover entry pointer ; OK, we have the font we wish. See if it is in the ; PageFont array already. Need to check both ID and style ; If it's there, we're done. If it isn't, then realloc the ; chunk bigger and copy it over. ; For 1.2, just check the ID, since we never have the font ; driver do styles havePageFont: mov si, di ; bump to next entry mov cx, es:[si-2] ; cx = #entries jcxz addEntry ; none yet, add this one mov dx, es:[si].PF_id ; load up compare values mov al, es:[si].PF_style checkPFloop: add di, size PageFont ; ds:di -> next entry cmp es:[di].PF_id, dx ; same id ? jne nextEntry ; nope, continue cmp es:[di].PF_style, al ; same style ? je done ; yes, all done nextEntry: loop checkPFloop ; we don't have this font yet. Alloc a new entry for the ; array and copy the info to the last element addEntry: segmov ds, es, di sub si, offset PF_first ; ds:si -> beginning of chunk mov ax, tgs.TGS_pageFonts.chunk ; handle in ax ChunkSizePtr ds, si, cx ; cx = chunk size add cx, size PageFont ; make room for another call LMemReAlloc ; reallocate block mov si, ax ; deref chunk again mov si, ds:[si] ; ds:si -> chunk inc ds:[si].PF_count ; bump the count of structs mov di, si ; set up es:di -> chunk add si, offset PF_first ; ds:si -> scratch element add di, cx ; es:di -> past end of chunk mov cx, size PageFont sub di, cx ; es:di -> last array elemet rep movsb ; copy PageFont element sub di, size PageFont ; es:di -> PageFont element ; either we just copied one or we don't need to copy one done: .leave ret GetPageFontEntry endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MapFontToPostScript %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: get the PS name for our fontID CALLED BY: INTERNAL GetPageFontEntry PASS: cx - fontID al - style bits es:di - pointer to PageFont structure RETURN: es:di - PageFont structure filled in with info on closest Adobe font that is resident in the printer. dh - factor of "closesness" for font DESTROYED: dl PSEUDO CODE/STRATEGY: if (adobe fontID) write adobe name else map to adobe font ID if (fontID is in supported font list for printer) write equivalent name else using fontID, map to something intelligent. KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 04/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ MapFontToPostScript proc near uses ax, bx, cx, ds, si tgs local TGSLocals .enter inherit mov es:[di].PF_style, al ; save style bits push di ; pointer to PageFont struct push ax and al, mask TS_ITALIC or mask TS_BOLD ; only look for these ; if it is an Adobe ID, skip the mapping function mov bx, cx and bx, 0xf000 ; isolate manufacturer info cmp bx, FM_ADOBE je haveAdobe and cx, not 0xf000 ; clear manufacturer ID or cx, FM_ADOBE ; force adobe haveAdobe: ; have an Adobe-type fontID. Look it up in the table ; register usage: ; ds:di - points to closes match so far ; dl - had difference in style bits for entry @ds:di ; dh - hold ID difference, from CalcFontDiff ; ds:si - points to next entry to check ; ds:bx - points into table of entry pointers ; al - holds desired style ; cx - holds desired fontID mov ds, tgs.TGS_options ; get pointer to options blk mov bx, ds:[PSEO_fonts] ; get font enum mov dx, cs:[fontMapOffsets][bx] ; look at right table mov bx, cs:[fontMapHandles][bx] ; look at right table push bx push ax ; save style bits call MemLock mov ds, ax pop ax ; restore style bits mov bx, dx ; ds:bx -> table of tables ; set up really bad values so we pick the first element in ; the table mov dh, FM_DONT_USE ; worse difference in fontIDs mov dl, 0xff ; worse difference in styles mov di, ds:[bx] ; point at first element ; loop through all the font tables. tableLoop: push bx ; save table pointer mov bx, ds:[bx] ; load up pointer to table tst bx ; if zero, we're done jz foundFont ; loop through all the font entries. Like Mary Poppins, we ; want it Practically Perfect in Every Way. fontLoop: mov si, ds:[bx] ; ds:bx -> entry tst si ; check for terminator jz nextFontTable ; all done, no match push bx ; calculate the font difference push ax mov bx, ds:[si].AFE_id ; get ID of font to check mov ax, cx ; check this one call CalcFontDiff cmp cl, dh ; is it better ? jb haveSomething ; maybe, keep checking mov cx, ax ; restore desired font pop ax ; restore desired style je checkStyle ; id is same -- check style jmp nextFontEntry ; no, not better. skip it. ; might have a better candidate. see if we need to check style haveSomething: mov dh, cl ; save new id diff mov cx, ax ; restore desired font pop ax ; restore desired style ; found a better font. store some info about it and check to ; see if we have an exact match. haveBetterEntry: mov dl, ds:[si].AFE_style ; else get the new style too xor dl, al ; store difference mov di, si tst dx ; if exact, use it ! jz foundFontInt nextFontEntry: pop bx add bx, 2 ; bump to next entry jmp fontLoop nextFontTable: pop bx ; restore table pointer add bx, 2 ; bump to next table pointer jmp tableLoop ;------------------------------------------------------------------------- ; ID is same as the one we have so far. See if style is ; better checkStyle: mov ah, ds:[si].AFE_style ; get style of candidate xor ah, al ; get difference cmp ah, dl ; better than before ? jae nextFontEntry ; no, keep looking jmp haveBetterEntry ; have it as close as it gets. ds:di -> font entry foundFontInt: add sp, 2 ; pop table pointer foundFont: EC < tst di ; if zero, it's bad > EC < ERROR_Z PS_BAD_ADOBE_FONT_MAP_TABLE > add sp, 2 ; don't care about font ptr ; ds:di points at the font. Get the length of the string, ; and calculate the modified style bits. mov si, di ; ds:si -> entry pop bx ; restore handle pop ax ; restore original style pop di ; restore buffer pointer push di ; save it again mov cl, ds:[si].AFE_nlen ; get name length mov es:[di].PF_nlen, cl ; save it clr ch mov ah, ds:[si].AFE_style ; get style bits not ah and al, ah ; zero out those bits mov es:[di].PF_newstyle, al ; save what the result it mov dl, ds:[si].AFE_encode ; get encoding to check special cmp dl, AFE_STANDARD ; if standard, reencode jne copyName or es:[di].PF_flags, mask PFF_REENCODE copyName: add si, AFE_name ; ds:si -> name add di, offset PF_name ; setup to copy name rep movsb ; copy the name over pop di ; restore pointer to struct start call MemUnlock ; release font name segment .leave ret MapFontToPostScript endp ExportText ends ExportType3Font segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DownloadPageFonts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Download any fonts that we need to CALLED BY: INTERNAL TranslateGStringCommon PASS: tgs - inherited stack frame RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: Check each font that we scanned the page for. If it needs to be downloaded, do it KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 06/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DownloadPageFonts proc far uses ax, bx, cx, ds, si tgs local TGSLocals .enter inherit ; lock down the block that the font descriptions are held ; and loop through each one mov bx, tgs.TGS_pageFonts.handle ; get block handle call MemLock ; lock block mov ds, ax ; ds -> block mov si, tgs.TGS_pageFonts.chunk ; get chunk handle mov si, ds:[si] ; deref handle ; grab the number of fonts we need to check, then go to it mov cx, ds:[si].PF_count ; #fonts to check jcxz done ; handle no fonts add si, offset PF_first ; point to scratch fontLoop: add si, size PageFont ; bump to next entry test ds:[si].PF_flags, mask PFF_DOWNLOAD ; check font type jz nextEntry ; nope, continue call DownloadFont ; do this one nextEntry: loop fontLoop ; done downloading what we need. continue done: mov bx, tgs.TGS_pageFonts.handle ; release block call MemUnlock .leave ret DownloadPageFonts endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DownloadFont %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Download a single font CALLED BY: INTERNAL DownloadPageFonts PASS: ds:si - points at PageFont entry of font to download RETURN: ds:si - points at same PageFont entry (may have changed) DESTROYED: nothing PSEUDO CODE/STRATEGY: fill in a template and write it out. only write out the characters that we need first download the header then download the individual character encodings then download the character definitions then download a trailer then enter the available font table KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 06/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DOWNLOAD_FONT_OVERHEAD equ 12 MINIMUM_PS_VM_REQUIRED equ 30 DownloadFont proc near uses ax, bx, es, cx, dx, di tgs local TGSLocals .enter inherit ; first count the characters that we need to download. ; We need this for a few things... call CountCharsToDownload ; cx = #chars ; dx = max char # ; download the header call DownloadFontHeader ; emit the encoding vector call EmitEncoding ; we're done encoding, so we're going to have to start calling ; the font driver to get the right paths for the characters. ; before we do that, we need the font manufacturer code, ; which we have to get via some hacking. (don't look). ; note: we know that we always have an outline font here, since ; all bitmap (non-outline) fonts will be mapped to Times-Roman. push ds:[si].PF_id ; save font id mov bx, tgs.TGS_chunk.handle ; make a gstring call MemDerefDS ; ds -> LMem block mov ax, tgs.TGS_chunk.chunk ; ^lbx:si -> chunk call LMemFree mov bx, tgs.TGS_chunk.handle ; make a gstring call MemUnlock ; release it mov cl, GST_CHUNK ; signal its a chunk call GrCreateGString ; di = gstate struct mov tgs.TGS_chunk.chunk, si ; store new chunk han pop cx ; restore font id mov dx, 1 ; set ps = 1.0 points clr ax call GrSetFont ; for 1.2 we're going to simulate ALL style in PostScript. ; For 2.0, we'll want to change this and get the largest ; subset of styles that the actual outline data supports. mov ax, 0xff00 ; restore style bits call GrSetTextStyle ; initialize the various variables we keep track of clr ax ; clear FontBBox mov tgs.TGS_fontBBox.R_right, ax mov tgs.TGS_fontBBox.R_top, ax mov ah, 40h mov tgs.TGS_fontBBox.R_bottom, ax mov tgs.TGS_fontBBox.R_left, ax ; before we start spewing characters, get the font matrix, so ; we don't get it for every character. Just use any char here. call GrSaveState ; save current state mov ax, DR_FONT_GEN_PATH ; di = driver function mov dl, 'a' ; use any char clr dh mov cl, mask FGPF_POSTSCRIPT push di ; save gstate handle mov bx, di call GrCallFontDriver ; draw the character pop di ; restore gstate handle segmov ds, ss, si lea si, tgs.TGS_matrix ; place to put matrix call GrGetTransform ; get font matrix call GrRestoreState push di ; save GState handle segmov ds, es, si ; ds -> PSType3 mov bx, tgs.TGS_stream ; get stream blk handle EmitPS emitFontMatrix ; "/FontMatrix " segmov es, ss, di lea di, tgs.TGS_buffer ; es:di -> buffer call MatrixToAscii mov si, offset emitFMDef mov cx, length emitFMDef rep movsb call EmitBuffer ; now we need to open the CharProcs dict and write out ; each of the character drawing procedures mov bx, tgs.TGS_stream ; get stream blk handle EmitPS cpstart segmov es, ds, si ; es -> PSType3 mov bx, tgs.TGS_chunk.handle ; relock the block call MemLock mov ds, ax ; ds -> font block pop dx ; restore gstate han ; for each bit set in the character map, emit the code to ; draw the character call EmitFontCharacters ; emit em all mov bx, tgs.TGS_chunk.handle ; deref again 2b sure call MemDerefDS ; ds -> PageFonts ; done sending all the character definitions. output ; a bounding box and close the dict mov si, dx ; si = gstring handle clr di ; di = gstate handle (0) mov dl, GSKT_LEAVE_DATA call GrDestroyGString ; finished with it push ds, es segmov ds, es ; ds -> PSType3 mov bx, tgs.TGS_stream ; get stream blk handle EmitPS emitFontBBox ; output start segmov es, ss, di lea di, tgs.TGS_buffer mov bx, tgs.TGS_fontBBox.R_left ; output BBox info call SWordToAscii ; write left mov al, ' ' stosb mov bx, tgs.TGS_fontBBox.R_bottom call SWordToAscii ; write bottom stosb mov bx, tgs.TGS_fontBBox.R_right call SWordToAscii ; write right stosb mov bx, tgs.TGS_fontBBox.R_top call SWordToAscii ; write top call EmitBuffer mov bx, tgs.TGS_stream EmitPS emitBBDef ; close bracket def EmitPS cpend ; close dictionary pop ds, es ; es -> PSType3 ; ds -> PageFonts ; output the name of the font mov si, tgs.TGS_pageFonts.chunk ; deref chunk again mov si, ds:[si] add si, tgs.TGS_nchars ; add in chunk offset mov cl, ds:[si].PF_nlen ; get length of name clr ch mov dx, si add dx, offset PF_name ; ds:dx -> name clr al ; handle errors call SendToStream push ds segmov ds, es EmitPS emitDefineFont ; make it official pop ds ; finished with the resource now... mov bx, handle PSType3 ; release resource call MemUnlock .leave ret DownloadFont endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CountCharsToDownload %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Count the #chars that we will be downloading CALLED BY: INTERNAL DownloadFont PASS: ds:si - pointer to PageFont entry for font to download RETURN: cx - #chars in PF_map dx - code of highest #char DESTROYED: nothing PSEUDO CODE/STRATEGY: for each bit set in the PF_map field, inc the count KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 06/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CountCharsToDownload proc near uses si, ax, bx .enter clr cx ; start at beginning clr bx ; to determine done clr dx ; to determine done mov al, 0x80 ; initial bit mask add si, offset PF_map testNextBit: test ds:[si], al ; check bit jz nextBit inc cx ; one more to download mov dx, bx ; update maximum nextBit: inc bx ; on to next one tst bh ; when non-zero, done jnz done shr al, 1 ; to next bit jnc testNextBit mov al, 0x80 inc si jmp testNextBit done: .leave ret CountCharsToDownload endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DownloadFontHeader %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Write out some PostScript for the font header CALLED BY: INTERNAL DownloadFont PASS: tgs - stack frame cx = #chars to download dx = max char code we're downloading ds:si - pointer to PageFont structure block RETURN: es - pointer to locked PSType3 resource. caller should unlock DESTROYED: cx, dx, bx, ax, di PSEUDO CODE/STRATEGY: yeah, copy some PS code over KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 06/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DownloadFontHeader proc near tgs local TGSLocals .enter inherit ; create the font header. first lock the right resrouce push ds ; save pointer to font push cx ; save #chars mov bx, tgs.TGS_pageFonts.chunk ; deref chunk handle mov bx, ds:[bx] sub bx, si ; get offset neg bx ; into chunk mov tgs.TGS_nchars, bx ; save it (reuse var) mov bx, handle PSType3 ; get resource call MemLock ; lock it down mov ds, ax ; ds -> resource ; mov bx, tgs.TGS_stream ; get stream blk handle ; EmitPS emitVMtest ; write out code to ; check for enuf mem ; pop bx ; restore #chars ; push bx ; save #chars ; reserve 1K/char + ; some overhead ; shr bx, 1 ; about 1/2K per char ; add bx, DOWNLOAD_FONT_OVERHEAD + MINIMUM_PS_VM_REQUIRED segmov es, ss, di ; set up buffer lea di, tgs.TGS_buffer ; es:di -> space ; call UWordToAscii ; this many 1000s ; call EmitBuffer ; write it out mov dx, offset beginType3Header mov cx, offset endType3Header - offset beginType3Header mov bx, tgs.TGS_stream ; get stream blk handle clr al call SendToStream ; set up CharProcs dictionary EmitPS emitCPstart ; define the CharProcs pop bx inc bx ; for .notdef lea di, tgs.TGS_buffer ; es:di -> space call UWordToAscii ; this many entries call EmitBuffer ; write it out mov dx, offset beginCPdefine mov cx, offset endCPdefine - offset beginCPdefine mov bx, tgs.TGS_stream ; get stream blk handle clr al call SendToStream ; emit info about encoding vector mov dx, offset beginEVdefine mov cx, offset endEVdefine - offset beginEVdefine mov bx, tgs.TGS_stream ; get stream blk handle clr al call SendToStream segmov es, ds, ax ; put it here for later pop ds ; ds:si -> font entry .leave ret DownloadFontHeader endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitFontCharacters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Write out all the chars for a font CALLED BY: INTERNAL DownloadFont PASS: ds - pointer to PageFont structure block dx - GState handle RETURN: bx - pointer to chunk where PageFont structure is DESTROYED: ax, cx, di PSEUDO CODE/STRATEGY: For each character in the PF_map: EmitCharacter KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitFontCharacters proc near tgs local TGSLocals .enter inherit clr ax ; start at beginning mov cl, 0x80 ; initial bit mask mov bx, tgs.TGS_pageFonts.chunk ; dereference chunk mov bx, ds:[bx] ; mov di, tgs.TGS_nchars ; add offset into chunk add di, offset PF_map testNextChar: test ds:[bx][di], cl ; check bit jz nextChar xchg di, dx ; di = GState call GrSaveState mov bx, tgs.TGS_chunk.handle ; chunk can move after call MemDerefDS ; ...GString op xchg di, dx call EmitCharacter ; emit encoding info xchg di, dx call GrRestoreState xchg di, dx mov bx, tgs.TGS_chunk.handle ; chunk can move after call MemDerefDS ; ...GString op mov bx, tgs.TGS_pageFonts.chunk ; dereference chunk mov bx, ds:[bx] nextChar: inc ax ; on to next one tst ah ; when non-zero, done jnz done shr cl, 1 ; to next bit jnc testNextChar mov cl, 0x80 inc di jmp testNextChar done: .leave ret EmitFontCharacters endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitCharacter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Write out a line to set the encoding for a character CALLED BY: INTERNAL DownloadFont PASS: al - character code ds:bx - pointer to chunk with PageFont info TGS_nchars - offset into chunk of current PageFont struct tgs - inherited stack frame dx, di - gstate to use RETURN: ds - points to same segment (may have moved) DESTROYED: bx PSEUDO CODE/STRATEGY: write out the PS necc to draw the character something like: /c97 {0 0 m 0 1 l .... F} bind def We'll get the information about the drawing commands from calls into the font driver. Also, we need to keep running track of the overall font bounding box, and save off the font matrix. Both of these pieces of info are returned by the font driver for each char. KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 06/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitCharacter proc near uses ax, cx, dx, di, es tgs local TGSLocals .enter inherit ; write out the beginning stuff push dx ; save GState handle mov dl, al ; dl = char code segmov es, ss, di lea di, tgs.TGS_buffer ; es:di -> buffer space mov {byte} es:[di], '/' ; write as name mov {byte} es:[di+1], 'c' ; write as name add di, 2 push bx mov bl, al clr bh call UWordToAscii ; complete name pop bx mov al, ' ' ; space separator mov ah, '<' ; open hex string brace stosw ; set up a graphics string to put the char path into. ; first zero out the chunk we're going to use. mov ax, tgs.TGS_chunk.chunk ; resize it to zero clr cx call LMemReAlloc ; ds already points there mov bx, tgs.TGS_chunk.handle ; release block while writing call MemUnlock pop bx ; restore GState handle push di ; save buffer offset ; call the font driver to get the path description ; dl already has character to get mov di, bx ; di = GState handle mov ax, DR_FONT_GEN_PATH ; mov cl, mask FGPF_POSTSCRIPT clr dh call GrCallFontDriver ; get char path ; since we have the block locked that was drawn into, it ; may have moved. Get the address once again. mov bx, tgs.TGS_chunk.handle ; relock the block call MemLock mov ds, ax ; OK, now the chunk at tgs.TGS_chunk has the graphics string ; in it, this consists of: ; ; GR_COMMENT wx wy llx lly urx ury ; GR_APPLY_TRANSLATION x y ; GR_APPLY_TRANSFORM transmatrix ; { drawing commands } ; ; we need to do a few things. First, update the fontBBox ; with this new info about the size of this character. Then ; scan through the graphics string and emit args/operators pop di ; restore buffer offset mov si, tgs.TGS_chunk.chunk ; get chunk handle ChunkSizeHandle ds, si, dx ; load chunk size into dx cmp dx, 0 ; if zero, nothing to do LONG jz doneChar ; just exit mov si, ds:[si] ; deref handle add dx, si ; dx = byte after chunk end lodsb ; get byte EC < cmp al, GR_COMMENT ; looking for a good comment > EC < ERROR_NE PS_BAD_CHAR_PATH > lodsw ; load size info EC < cmp ax, size CharSizeInfo ; should be 6 words > EC < ERROR_NE PS_BAD_CHAR_PATH > mov bx, ds:[si].CSI_wx ; set up to write width call HexEncodeSWord ; write it out mov bx, ds:[si].CSI_wy ; set up to write height call HexEncodeSWord ; write it out mov bx, ds:[si].CSI_llx ; get bounds info cmp tgs.TGS_fontBBox.R_left, bx ; see if we should update jle leftUpdated ; no, continue mov tgs.TGS_fontBBox.R_left, bx leftUpdated: call HexEncodeSWord ; write out left bounds mov bx, ds:[si].CSI_lly ; get bounds info cmp tgs.TGS_fontBBox.R_bottom, bx ; see if we should update jle bottomUpdated ; no, continue mov tgs.TGS_fontBBox.R_bottom, bx bottomUpdated: call HexEncodeSWord ; write out left bounds mov bx, ds:[si].CSI_urx ; get bounds info cmp tgs.TGS_fontBBox.R_right, bx ; see if we should update jge rightUpdated ; no, continue mov tgs.TGS_fontBBox.R_right, bx rightUpdated: call HexEncodeSWord ; write out left bounds mov bx, ds:[si].CSI_ury ; get bounds info cmp tgs.TGS_fontBBox.R_top, bx ; see if we should update jge topUpdated ; no, continue mov tgs.TGS_fontBBox.R_top, bx topUpdated: call HexEncodeSWord ; write out left bounds mov al, '0' mov ah, HO_SETCACHE ; setcachedevice proc stosw ; 1 more space add si, size CharSizeInfo + \ size OpApplyTranslation + \ size OpApplyTransform ; bump past GR_APPLY_TRANSFORM ; finally, we're ready to output the path construction operators ; loop until we're done with the whole chunk ; at this point: ; ds:si -> first path construction operator ; ds:dx -> first byte past end of chunk ; es:di -> pointer into buffer to write PS code ; the path construction operators include (for version 1.2) ; GR_DRAW_LINE_TO, GR_MOVE_TO, GR_DRAW_HLINE_TO, ; GR_DRAW_VLINE_TO, GR_DRAW_SPLINE ; we will re-use the TGS_bmXres and Yres for the current pos mov tgs.TGS_bmXres, 8000h ; current xpos mov tgs.TGS_bmYres, 8000h ; current ypos clr tgs.TGS_bmWidth ; clear translation clr tgs.TGS_bmHeight ; clear translation cmp si, dx ; if past end already, quit jae doneChar pathLoop: mov al, ds:[si] ; get next opcode mov bx, offset cs:EmitLineto cmp al, GR_DRAW_LINE_TO je haveOpcode mov bx, offset cs:EmitRelLineto cmp al, GR_DRAW_REL_LINE_TO je haveOpcode mov bx, offset cs:EmitMoveto cmp al, GR_MOVE_TO je haveOpcode mov bx, offset cs:EmitHLineto cmp al, GR_DRAW_HLINE_TO je haveOpcode mov bx, offset cs:EmitVLineto cmp al, GR_DRAW_VLINE_TO je haveOpcode mov bx, offset cs:EmitTranslation cmp al, GR_APPLY_TRANSLATION je haveOpcode mov bx, offset cs:EmitCurveto cmp al, GR_DRAW_CURVE_TO je haveOpcode mov bx, offset cs:EmitRelCurveto cmp al, GR_DRAW_REL_CURVE_TO je haveOpcode mov bx, offset cs:EmitSpline EC < cmp al, GR_DRAW_SPLINE > EC < ERROR_NE PS_BAD_CHAR_PATH > haveOpcode: call bx ; call handler, si updated mov bx, tgs.TGS_chunk.handle ; just in case call MemDerefDS ; ds -> PageFonts cmp si, dx ; past end ? jb pathLoop ; done with chunk. Output closing brace and other nice stuff mov al, '0' mov ah, HO_FILL ; fill the character stosw doneChar: push ds segmov ds, cs, si mov si, offset emitCharDef mov cx, length emitCharDef rep movsb pop ds call EmitBuffer ; write it out to the stream .leave ret EmitCharacter endp emitCharDef char "> def", NL COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitLineto %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: write out a PS lineto command CALLED BY: INTERNAL EmitCharacter PASS: ds:si - points to OpDrawLineTo es:di - where to write postscript RETURN: ds:si - points after OpDrawLineTo es:di - where to write next postscript code DESTROYED: ax, bx PSEUDO CODE/STRATEGY: write out: x y l update current position KNOWN BUGS/SIDE EFFECTS/IDEAS: FOR 2.0. we can optimize this by calculating deltax and deltay and using rlineto instead of lineto where it is appropriate. This would tend to decrease the size of the output stream. REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ MAX_LINE_SIZE equ 55 EmitLineto proc near tgs local TGSLocals .enter inherit ; update current position, output x mov bx, ds:[si].ODLT_x2 ; get x position add bx, tgs.TGS_bmWidth ; apply translation mov tgs.TGS_bmXres, bx ; update curXpos call HexEncodeSWord ; output ascii rep mov bx, ds:[si].ODLT_y2 ; get y position add bx, tgs.TGS_bmHeight ; apply translation mov tgs.TGS_bmYres, bx ; update curYpos call HexEncodeSWord ; output ascii rep mov al, '0' mov ah, HO_LINETO ; lineto command stosw ; final space lea ax, tgs.TGS_buffer ; see if we're full yet sub ax, di ; check buffer size neg ax cmp ax, MAX_LINE_SIZE ; output buffer if over 70 chars jb done call EmitBuffer lea di, tgs.TGS_buffer ; reset pointer done: add si, size OpDrawLineTo ; bump over element .leave ret EmitLineto endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitRelLineto %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: write out a PS rlineto command CALLED BY: INTERNAL EmitCharacter PASS: ds:si - points to OpDrawRelLineTo es:di - where to write postscript RETURN: ds:si - points after OpDrawRelLineTo es:di - where to write next postscript code DESTROYED: ax, bx PSEUDO CODE/STRATEGY: write out: x y rl update current position KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitRelLineto proc near tgs local TGSLocals .enter inherit ; update current position, output x mov bx, ds:[si].ODRLT_x2.WWF_int ; get x position tst ds:[si].ODRLT_x2.WWF_frac ; round if needed jns haveXoff inc bx haveXoff: ; add bx, tgs.TGS_bmWidth ; apply translation ; mov tgs.TGS_bmXres, bx ; update curXpos add tgs.TGS_bmXres, bx ; update curXpos call HexEncodeSWord ; output ascii rep mov bx, ds:[si].ODRLT_y2.WWF_int ; get y position tst ds:[si].ODRLT_y2.WWF_frac ; round if needed jns haveYoff inc bx haveYoff: ; add bx, tgs.TGS_bmHeight ; apply translation ; mov tgs.TGS_bmYres, bx ; update curYpos add tgs.TGS_bmYres, bx ; update curYpos call HexEncodeSWord ; output ascii rep mov al, '0' mov ah, HO_RLINETO ; lineto command stosw ; final space lea ax, tgs.TGS_buffer ; see if we're full yet sub ax, di ; check buffer size neg ax cmp ax, MAX_LINE_SIZE ; output buff if over 70 chars jb done call EmitBuffer lea di, tgs.TGS_buffer ; reset pointer done: add si, size OpDrawRelLineTo ; bump over element .leave ret EmitRelLineto endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitMoveto %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: write out a PS moveto command CALLED BY: INTERNAL EmitCharacter PASS: ds:si - points to OpMoveTo es:di - where to write postscript RETURN: ds:si - points after OpMoveTo es:di - where to write next postscript code DESTROYED: ax, bx PSEUDO CODE/STRATEGY: write out: x y m update current position KNOWN BUGS/SIDE EFFECTS/IDEAS: FOR 2.0. we can optimize this by calculating deltax and deltay and using rlineto instead of lineto where it is appropriate. This would tend to decrease the size of the output stream. REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitMoveto proc near tgs local TGSLocals .enter inherit ; update current position, output x mov bx, ds:[si].OMT_x1 ; get x position add bx, tgs.TGS_bmWidth ; apply translation mov ax, ds:[si].OMT_y1 add ax, tgs.TGS_bmHeight ; apply translation cmp bx, tgs.TGS_bmXres ; check to see if changed jne doIt cmp ax, tgs.TGS_bmYres je done ; don't do anything if unchange doIt: mov tgs.TGS_bmXres, bx ; update curXpos call HexEncodeSWord ; output ascii rep mov bx, ax mov tgs.TGS_bmYres, bx ; update curYpos call HexEncodeSWord ; output ascii rep mov al, '0' mov ah, HO_MOVETO ; moveto command stosw ; final space lea ax, tgs.TGS_buffer ; see if we're full yet sub ax, di ; check buffer size neg ax cmp ax, MAX_LINE_SIZE ; output buffer if over 70 chars jb done mov al, C_CR ; terminate line mov ah, C_LF stosw call EmitBuffer lea di, tgs.TGS_buffer ; reset pointer done: add si, size OpMoveTo ; bump past element .leave ret EmitMoveto endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitHLineto %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: write out a PS lineto command CALLED BY: INTERNAL EmitCharacter PASS: ds:si - points to OpDrawHLineTo es:di - where to write postscript RETURN: ds:si - points after OpDrawHLineTo es:di - where to write next postscript code DESTROYED: ax, bx PSEUDO CODE/STRATEGY: write out: deltax 0 r update current position KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitHLineto proc near tgs local TGSLocals .enter inherit ; update current position, output x mov bx, ds:[si].ODHLT_x2 ; get x position add bx, tgs.TGS_bmWidth ; apply x translation mov ax, bx ; save it xchg ax, tgs.TGS_bmXres ; update curpos sub bx, ax ; calc relative lineto call HexEncodeSWord ; output ascii rep mov al, '0' mov ah, HO_HLINETO ; rlineto command stosw ; final space lea ax, tgs.TGS_buffer ; see if we're full yet sub ax, di ; check buffer size neg ax cmp ax, MAX_LINE_SIZE ; output buffer if over 70 chars jb done mov al, C_CR ; terminate line mov ah, C_LF stosw call EmitBuffer lea di, tgs.TGS_buffer ; reset pointer done: add si, size OpDrawHLineTo ; bump past element .leave ret EmitHLineto endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitVLineto %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: write out a PS lineto command CALLED BY: INTERNAL EmitCharacter PASS: ds:si - points to OpDrawVLineTo es:di - where to write postscript RETURN: ds:si - points after OpDrawVLineTo es:di - where to write next postscript code DESTROYED: ax, bx PSEUDO CODE/STRATEGY: write out: 0 deltay r update current position KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitVLineto proc near tgs local TGSLocals .enter inherit ; update current position, output x mov bx, ds:[si].ODVLT_y2 ; get y position add bx, tgs.TGS_bmHeight ; apply translation mov ax, bx ; save it xchg ax, tgs.TGS_bmYres ; update curpos sub bx, ax ; calc relative lineto call HexEncodeSWord ; output ascii rep mov al, '0' mov ah, HO_VLINETO ; rlineto command stosw ; final space lea ax, tgs.TGS_buffer ; see if we're full yet sub ax, di ; check buffer size neg ax cmp ax, MAX_LINE_SIZE ; output buffer if over 70 chars jb done mov al, C_CR ; terminate line mov ah, C_LF stosw call EmitBuffer lea di, tgs.TGS_buffer ; reset pointer done: add si, size OpDrawVLineTo ; bump past element .leave ret EmitVLineto endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitSpline %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: write out a PS curveto command CALLED BY: INTERNAL EmitCharacter PASS: ds:si - points to OpDrawSpline es:di - where to write postscript RETURN: ds:si - points after OpDrawSpline es:di - where to write next postscript code DESTROYED: ax, bx PSEUDO CODE/STRATEGY: write out: x y c update current position KNOWN BUGS/SIDE EFFECTS/IDEAS: FOR 2.0. we can optimize this by calculating deltax and deltay and using rlineto instead of lineto where it is appropriate. This would tend to decrease the size of the output stream. REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitSpline proc near tgs local TGSLocals .enter inherit ; check to see if the first point is at the current position ; (it should be). If not, then output a moveto command. EC < cmp ds:[si].ODS_count, 4 ; should only be this many > EC < ERROR_NE PS_BAD_CHAR_PATH > add si, size OpDrawSpline ; get to the data lodsw ; make sure we're at the current mov bx, ax ; point lodsw add bx, tgs.TGS_bmWidth ; add in translation cmp bx, tgs.TGS_bmXres ; check x coord jne outputMoveto add ax, tgs.TGS_bmHeight ; add in translation cmp ax, tgs.TGS_bmYres ; check y coord je doneMoveto outputMoveto: add bx, tgs.TGS_bmWidth ; apply any translation call HexEncodeSWord ; write out x coord mov bx, ax ; write out y coord add bx, tgs.TGS_bmHeight ; apply any translation call HexEncodeSWord mov al, '0' mov ah, HO_MOVETO stosw ; output the three coords and a curveto command doneMoveto: mov ax, ds:[si+8] ; update curpos first add ax, tgs.TGS_bmWidth ; add in translation mov tgs.TGS_bmXres, ax mov ax, ds:[si+10] add ax, tgs.TGS_bmHeight ; add in translation mov tgs.TGS_bmYres, ax call OutputCoordPair call OutputCoordPair call OutputCoordPair mov al, '0' mov ah, HO_CURVETO ; write curveto command stosw lea ax, tgs.TGS_buffer ; see if we're full yet sub ax, di ; check buffer size neg ax cmp ax, MAX_LINE_SIZE ; output buffer if over 70 chars jb done mov al, C_CR ; terminate line mov ah, C_LF stosw call EmitBuffer lea di, tgs.TGS_buffer ; reset pointer done: .leave ret EmitSpline endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitCurveTo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: write out a PS curveto command CALLED BY: INTERNAL EmitCharacter PASS: ds:si - points to OpDrawCurveTo es:di - where to write postscript RETURN: ds:si - points after OpDrawCurveTo es:di - where to write next postscript code DESTROYED: ax, bx PSEUDO CODE/STRATEGY: write out: x2 y2 x3 y3 x4 y4 c update current position KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitCurveto proc near tgs local TGSLocals .enter inherit ; output the three coords and a curveto command mov ax, ds:[si].ODCVT_x4 ; update curpos first add ax, tgs.TGS_bmWidth ; add in translation mov tgs.TGS_bmXres, ax mov ax, ds:[si].ODCVT_y4 add ax, tgs.TGS_bmHeight ; add in translation mov tgs.TGS_bmYres, ax add si, offset ODCVT_x2 call OutputCoordPair call OutputCoordPair call OutputCoordPair mov al, '0' mov ah, HO_CURVETO ; write curveto command stosw lea ax, tgs.TGS_buffer ; see if we're full yet sub ax, di ; check buffer size neg ax cmp ax, MAX_LINE_SIZE ; output buffer if over 70 chars jb done mov al, C_CR ; terminate line mov ah, C_LF stosw call EmitBuffer lea di, tgs.TGS_buffer ; reset pointer done: .leave ret EmitCurveto endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitRelCurveTo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: write out a PS curveto command CALLED BY: INTERNAL EmitCharacter PASS: ds:si - points to OpDrawRelCurveTo es:di - where to write postscript RETURN: ds:si - points after OpDrawRelCurveTo es:di - where to write next postscript code DESTROYED: ax, bx PSEUDO CODE/STRATEGY: write out: x2 y2 x3 y3 x4 y4 rc update current position KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitRelCurveto proc near tgs local TGSLocals .enter inherit ; output the three offsets and an rcurveto command mov ax, ds:[si].ODRCVT_x4 ; update curpos first add tgs.TGS_bmXres, ax mov ax, ds:[si].ODRCVT_y4 add tgs.TGS_bmYres, ax add si, offset ODRCVT_x2 call OutputRelCoordPair call OutputRelCoordPair call OutputRelCoordPair mov al, '0' mov ah, HO_RCURVETO ; write curveto command stosw lea ax, tgs.TGS_buffer ; see if we're full yet sub ax, di ; check buffer size neg ax cmp ax, MAX_LINE_SIZE ; output buffer if over 70 chars jb done mov al, C_CR ; terminate line mov ah, C_LF stosw call EmitBuffer lea di, tgs.TGS_buffer ; reset pointer done: .leave ret EmitRelCurveto endp ; simple utility routine to read/write a pair of coords OutputRelCoordPair proc near tgs local TGSLocals .enter inherit lodsw mov bx, ax call HexEncodeSWord lodsw mov bx, ax call HexEncodeSWord .leave ret OutputRelCoordPair endp ; simple utility routine to read/write a pair of coords OutputCoordPair proc near tgs local TGSLocals .enter inherit lodsw add ax, tgs.TGS_bmWidth mov bx, ax call HexEncodeSWord lodsw add ax, tgs.TGS_bmHeight mov bx, ax call HexEncodeSWord .leave ret OutputCoordPair endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitTranslation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Write out a string CALLED BY: GLOBAL PASS: ds:si - points to OpApplyTranslation RETURN: ds:si - points to next element DESTROYED: ax PSEUDO CODE/STRATEGY: just store away the translation KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 06/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitTranslation proc near tgs local TGSLocals .enter inherit mov ax, ds:[si].OAT_x.WWF_int add tgs.TGS_bmWidth, ax mov ax, ds:[si].OAT_y.WWF_int add tgs.TGS_bmHeight, ax add si, size OpApplyTranslation .leave ret EmitTranslation endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% HexEncodeSWord %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Change an SWord value to hex-encoded ascii CALLED BY: INTERNAL various routines PASS: bx - value to convert es:di - buffer pointer to put hex ascii RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: This assumes the following encoding of values 0x0e-0xea - -110 thru 110 (0 = 7c) 0xeb-0xff - -1100 thru 1100 (0 = f5) So, for values whose absolute value is less than or equal to 110, we output two hex digits. For larger values, we decompose the value into at least four hex digits KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 06/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ HexEncodeSWord proc near uses ax, bx, cx .enter ; check to see if abs value is less than 110 mov ax, bx ; save value tst ax jns haveAbsValue neg ax haveAbsValue: mov cx, HO_DIGITS_RANGE ; divide by 110 div cl ; ah = remainder ; if original number was negative, then negate both remainder ; and quotient tst bx jns haveValuesToWrite neg al neg ah ; OK, we have what we need. First write out the single digit haveValuesToWrite: push ax ; save other digit mov al, ah ; do remainder first add al, HO_DIGITS_ZERO ; normalize it to encoded call ByteToHexAscii ; value ; next we need to keep writing 110s til we've accounted ; for the entire value pop cx ; restore value to cl clr ch ; we already did the remainder jcxz done ; nothing to write ; OK, we have the 110s digit to do. It's probably only one ; but we'll need to check to make sure. do110s: cmp cl, HO_110S_LOW ; check low side jl handleNeg cmp cl, HO_110S_HIGH ; and high side jg handlePos add cl, HO_110S_ZERO ; normalize it mov al, cl call ByteToHexAscii done: .leave ret ; number is way negative. Do something handleNeg: mov al, HO_110S_LOW + HO_110S_ZERO ; write out a -10 call ByteToHexAscii add cl, 10 ; smaller number now jmp do110s ; number is way positive. Do something handlePos: mov al, HO_110S_HIGH + HO_110S_ZERO ; write out a 10 call ByteToHexAscii sub cl, 10 ; smaller number now jmp do110s HexEncodeSWord endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EmitEncoding %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Write out a line to set the encoding for a character CALLED BY: INTERNAL DownloadFont PASS: es - locked PSType3 data resource tgs - inherited stack frame ds - pointer to PageFont entry RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: write out a packed array that hold the character values and some code to deal with it. KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 06/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EmitEncoding proc near uses ax, bx, cx, si, di tgs local TGSLocals .enter inherit ; for each character that we're going to download, put out ; a line something like ; Encoding 128 /80 put ; the "/80" is the internal name of the character. Usually, ; it's given some interesting name like "/space" or ; "/percent", but since this is all internal, let's stay with ; small names to keep memory usage low. and are easy to ; generate algorithmically. push ds ; save font seg push es ; save PSType3 seg segmov es, ss, di ; es:di -> buffer lea di, tgs.TGS_buffer mov al, '<' ; start hex string stosb mov si, tgs.TGS_pageFonts.chunk ; ds:si -> font mov si, ds:[si] add si, tgs.TGS_nchars ; ds:si -> PageFont entry clr bx ; start at beginning mov cl, 0x80 ; initial bit mask add si, offset PF_map testNextBit: test ds:[si], cl ; check bit jz nextBit push bx mov al, bl ; output hex bytes call ByteToHexAscii pop bx lea ax, tgs.TGS_buffer ; see if we're full yet sub ax, di ; check buffer size neg ax cmp ax, 70 ; output buffer if over 70 chars jb nextBit mov al, C_CR ; terminate line mov ah, C_LF stosw call EmitBuffer lea di, tgs.TGS_buffer ; reset pointer nextBit: inc bx ; on to next one tst bh ; when non-zero, done jnz done shr cl, 1 ; to next bit jnc testNextBit mov cl, 0x80 inc si jmp testNextBit ; done with all the characters. close out the array and ; do the actual encoding. done: call EmitBuffer pop ds ; ds -> PSType3 mov dx, offset emitEAend mov cx, length emitEAend clr al mov bx, tgs.TGS_stream call SendToStream segmov es,ds,si pop ds .leave ret EmitEncoding endp ExportType3Font ends
// Copyright (c) 2015-2021 Daniel Cooke // Use of this source code is governed by the MIT license that can be found in the LICENSE file. #ifndef active_region_generator_hpp #define active_region_generator_hpp #include <vector> #include <string> #include <functional> #include <algorithm> #include <boost/optional.hpp> #include "config/common.hpp" #include "basics/genomic_region.hpp" #include "basics/aligned_read.hpp" #include "basics/aligned_template.hpp" #include "io/reference/reference_genome.hpp" #include "utils/assembler_active_region_generator.hpp" namespace octopus { namespace coretools { class ActiveRegionGenerator { public: struct Options { bool assemble_all = false; boost::optional<AssemblerActiveRegionGenerator::Options> assembler_active_region_generator_options = boost::none; }; ActiveRegionGenerator() = delete; ActiveRegionGenerator(const ReferenceGenome& reference, Options options); ActiveRegionGenerator(const ActiveRegionGenerator&) = default; ActiveRegionGenerator& operator=(const ActiveRegionGenerator&) = default; ActiveRegionGenerator(ActiveRegionGenerator&&) = default; ActiveRegionGenerator& operator=(ActiveRegionGenerator&&) = default; ~ActiveRegionGenerator() = default; void add_generator(const std::string& name); void add_read(const SampleName& sample, const AlignedRead& read); void add_template(const SampleName& sample, const AlignedTemplate& reads); template <typename ForwardIterator> void add_reads(const SampleName& sample, ForwardIterator first, ForwardIterator last); std::vector<GenomicRegion> generate(const GenomicRegion& region, const std::string& generator) const; void clear() noexcept; private: struct RepeatRegions { GenomicRegion request_region; std::vector<GenomicRegion> minisatellites, compound_microsatellites; std::vector<GenomicRegion> assembler_microsatellites; }; struct AssemblerActiveRegions { GenomicRegion request_region; std::vector<GenomicRegion> active_regions; }; std::reference_wrapper<const ReferenceGenome> reference_; Options options_; std::string assembler_name_, cigar_scanner_name_; bool using_assembler_; boost::optional<AssemblerActiveRegionGenerator> assembler_active_region_generator_; std::size_t max_read_length_; mutable boost::optional<RepeatRegions> repeats_; mutable boost::optional<AssemblerActiveRegions> assembler_active_regions_; bool is_cigar_scanner(const std::string& generator) const noexcept; bool is_assembler(const std::string& generator) const noexcept; bool using_assembler() const noexcept; }; namespace detail { inline auto sequence_size_helper(const AlignedRead& read) { return sequence_size(read); } inline auto max_sequence_size(const AlignedTemplate& reads) { const static auto sequence_size_less = [] (const auto& lhs, const auto& rhs) { return sequence_size(lhs) < sequence_size(rhs); }; return sequence_size(*std::max_element(std::cbegin(reads), std::cend(reads), sequence_size_less)); } inline auto sequence_size_helper(const AlignedTemplate& reads) { return max_sequence_size(reads); } } // namespace detail template <typename ForwardIterator> void ActiveRegionGenerator::add_reads(const SampleName& sample, ForwardIterator first, ForwardIterator last) { if (assembler_active_region_generator_) assembler_active_region_generator_->add(sample, first, last); std::for_each(first, last, [this] (const auto& read) { max_read_length_ = std::max(max_read_length_, detail::sequence_size_helper(read)); }); } } // namespace coretools } // namespace octopus #endif
_wc: file format elf32-i386 Disassembly of section .text: 00000000 <wc>: char buf[512]; void wc(int fd, char *name) { 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 ec 48 sub $0x48,%esp int i, n; int l, w, c, inword; l = w = c = 0; 6: c7 45 e8 00 00 00 00 movl $0x0,-0x18(%ebp) d: 8b 45 e8 mov -0x18(%ebp),%eax 10: 89 45 ec mov %eax,-0x14(%ebp) 13: 8b 45 ec mov -0x14(%ebp),%eax 16: 89 45 f0 mov %eax,-0x10(%ebp) inword = 0; 19: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) while((n = read(fd, buf, sizeof(buf))) > 0){ 20: eb 68 jmp 8a <wc+0x8a> for(i=0; i<n; i++){ 22: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 29: eb 57 jmp 82 <wc+0x82> c++; 2b: 83 45 e8 01 addl $0x1,-0x18(%ebp) if(buf[i] == '\n') 2f: 8b 45 f4 mov -0xc(%ebp),%eax 32: 05 a0 0c 00 00 add $0xca0,%eax 37: 0f b6 00 movzbl (%eax),%eax 3a: 3c 0a cmp $0xa,%al 3c: 75 04 jne 42 <wc+0x42> l++; 3e: 83 45 f0 01 addl $0x1,-0x10(%ebp) if(strchr(" \r\t\n\v", buf[i])) 42: 8b 45 f4 mov -0xc(%ebp),%eax 45: 05 a0 0c 00 00 add $0xca0,%eax 4a: 0f b6 00 movzbl (%eax),%eax 4d: 0f be c0 movsbl %al,%eax 50: 89 44 24 04 mov %eax,0x4(%esp) 54: c7 04 24 ad 09 00 00 movl $0x9ad,(%esp) 5b: e8 58 02 00 00 call 2b8 <strchr> 60: 85 c0 test %eax,%eax 62: 74 09 je 6d <wc+0x6d> inword = 0; 64: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) 6b: eb 11 jmp 7e <wc+0x7e> else if(!inword){ 6d: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) 71: 75 0b jne 7e <wc+0x7e> w++; 73: 83 45 ec 01 addl $0x1,-0x14(%ebp) inword = 1; 77: c7 45 e4 01 00 00 00 movl $0x1,-0x1c(%ebp) int l, w, c, inword; l = w = c = 0; inword = 0; while((n = read(fd, buf, sizeof(buf))) > 0){ for(i=0; i<n; i++){ 7e: 83 45 f4 01 addl $0x1,-0xc(%ebp) 82: 8b 45 f4 mov -0xc(%ebp),%eax 85: 3b 45 e0 cmp -0x20(%ebp),%eax 88: 7c a1 jl 2b <wc+0x2b> int i, n; int l, w, c, inword; l = w = c = 0; inword = 0; while((n = read(fd, buf, sizeof(buf))) > 0){ 8a: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 91: 00 92: c7 44 24 04 a0 0c 00 movl $0xca0,0x4(%esp) 99: 00 9a: 8b 45 08 mov 0x8(%ebp),%eax 9d: 89 04 24 mov %eax,(%esp) a0: e8 b4 03 00 00 call 459 <read> a5: 89 45 e0 mov %eax,-0x20(%ebp) a8: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) ac: 0f 8f 70 ff ff ff jg 22 <wc+0x22> w++; inword = 1; } } } if(n < 0){ b2: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) b6: 79 19 jns d1 <wc+0xd1> printf(1, "wc: read error\n"); b8: c7 44 24 04 b3 09 00 movl $0x9b3,0x4(%esp) bf: 00 c0: c7 04 24 01 00 00 00 movl $0x1,(%esp) c7: e8 15 05 00 00 call 5e1 <printf> exit(); cc: e8 70 03 00 00 call 441 <exit> } printf(1, "%d %d %d %s\n", l, w, c, name); d1: 8b 45 0c mov 0xc(%ebp),%eax d4: 89 44 24 14 mov %eax,0x14(%esp) d8: 8b 45 e8 mov -0x18(%ebp),%eax db: 89 44 24 10 mov %eax,0x10(%esp) df: 8b 45 ec mov -0x14(%ebp),%eax e2: 89 44 24 0c mov %eax,0xc(%esp) e6: 8b 45 f0 mov -0x10(%ebp),%eax e9: 89 44 24 08 mov %eax,0x8(%esp) ed: c7 44 24 04 c3 09 00 movl $0x9c3,0x4(%esp) f4: 00 f5: c7 04 24 01 00 00 00 movl $0x1,(%esp) fc: e8 e0 04 00 00 call 5e1 <printf> } 101: c9 leave 102: c3 ret 00000103 <main>: int main(int argc, char *argv[]) { 103: 55 push %ebp 104: 89 e5 mov %esp,%ebp 106: 83 e4 f0 and $0xfffffff0,%esp 109: 83 ec 20 sub $0x20,%esp int fd, i; if(argc <= 1){ 10c: 83 7d 08 01 cmpl $0x1,0x8(%ebp) 110: 7f 19 jg 12b <main+0x28> wc(0, ""); 112: c7 44 24 04 d0 09 00 movl $0x9d0,0x4(%esp) 119: 00 11a: c7 04 24 00 00 00 00 movl $0x0,(%esp) 121: e8 da fe ff ff call 0 <wc> exit(); 126: e8 16 03 00 00 call 441 <exit> } for(i = 1; i < argc; i++){ 12b: c7 44 24 1c 01 00 00 movl $0x1,0x1c(%esp) 132: 00 133: e9 8f 00 00 00 jmp 1c7 <main+0xc4> if((fd = open(argv[i], 0)) < 0){ 138: 8b 44 24 1c mov 0x1c(%esp),%eax 13c: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 143: 8b 45 0c mov 0xc(%ebp),%eax 146: 01 d0 add %edx,%eax 148: 8b 00 mov (%eax),%eax 14a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 151: 00 152: 89 04 24 mov %eax,(%esp) 155: e8 27 03 00 00 call 481 <open> 15a: 89 44 24 18 mov %eax,0x18(%esp) 15e: 83 7c 24 18 00 cmpl $0x0,0x18(%esp) 163: 79 2f jns 194 <main+0x91> printf(1, "wc: cannot open %s\n", argv[i]); 165: 8b 44 24 1c mov 0x1c(%esp),%eax 169: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 170: 8b 45 0c mov 0xc(%ebp),%eax 173: 01 d0 add %edx,%eax 175: 8b 00 mov (%eax),%eax 177: 89 44 24 08 mov %eax,0x8(%esp) 17b: c7 44 24 04 d1 09 00 movl $0x9d1,0x4(%esp) 182: 00 183: c7 04 24 01 00 00 00 movl $0x1,(%esp) 18a: e8 52 04 00 00 call 5e1 <printf> exit(); 18f: e8 ad 02 00 00 call 441 <exit> } wc(fd, argv[i]); 194: 8b 44 24 1c mov 0x1c(%esp),%eax 198: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 19f: 8b 45 0c mov 0xc(%ebp),%eax 1a2: 01 d0 add %edx,%eax 1a4: 8b 00 mov (%eax),%eax 1a6: 89 44 24 04 mov %eax,0x4(%esp) 1aa: 8b 44 24 18 mov 0x18(%esp),%eax 1ae: 89 04 24 mov %eax,(%esp) 1b1: e8 4a fe ff ff call 0 <wc> close(fd); 1b6: 8b 44 24 18 mov 0x18(%esp),%eax 1ba: 89 04 24 mov %eax,(%esp) 1bd: e8 a7 02 00 00 call 469 <close> if(argc <= 1){ wc(0, ""); exit(); } for(i = 1; i < argc; i++){ 1c2: 83 44 24 1c 01 addl $0x1,0x1c(%esp) 1c7: 8b 44 24 1c mov 0x1c(%esp),%eax 1cb: 3b 45 08 cmp 0x8(%ebp),%eax 1ce: 0f 8c 64 ff ff ff jl 138 <main+0x35> exit(); } wc(fd, argv[i]); close(fd); } exit(); 1d4: e8 68 02 00 00 call 441 <exit> 000001d9 <stosb>: "cc"); } static inline void stosb(void *addr, int data, int cnt) { 1d9: 55 push %ebp 1da: 89 e5 mov %esp,%ebp 1dc: 57 push %edi 1dd: 53 push %ebx asm volatile("cld; rep stosb" : 1de: 8b 4d 08 mov 0x8(%ebp),%ecx 1e1: 8b 55 10 mov 0x10(%ebp),%edx 1e4: 8b 45 0c mov 0xc(%ebp),%eax 1e7: 89 cb mov %ecx,%ebx 1e9: 89 df mov %ebx,%edi 1eb: 89 d1 mov %edx,%ecx 1ed: fc cld 1ee: f3 aa rep stos %al,%es:(%edi) 1f0: 89 ca mov %ecx,%edx 1f2: 89 fb mov %edi,%ebx 1f4: 89 5d 08 mov %ebx,0x8(%ebp) 1f7: 89 55 10 mov %edx,0x10(%ebp) "=D" (addr), "=c" (cnt) : "0" (addr), "1" (cnt), "a" (data) : "memory", "cc"); } 1fa: 5b pop %ebx 1fb: 5f pop %edi 1fc: 5d pop %ebp 1fd: c3 ret 000001fe <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 1fe: 55 push %ebp 1ff: 89 e5 mov %esp,%ebp 201: 83 ec 10 sub $0x10,%esp char *os; os = s; 204: 8b 45 08 mov 0x8(%ebp),%eax 207: 89 45 fc mov %eax,-0x4(%ebp) while((*s++ = *t++) != 0) 20a: 90 nop 20b: 8b 45 08 mov 0x8(%ebp),%eax 20e: 8d 50 01 lea 0x1(%eax),%edx 211: 89 55 08 mov %edx,0x8(%ebp) 214: 8b 55 0c mov 0xc(%ebp),%edx 217: 8d 4a 01 lea 0x1(%edx),%ecx 21a: 89 4d 0c mov %ecx,0xc(%ebp) 21d: 0f b6 12 movzbl (%edx),%edx 220: 88 10 mov %dl,(%eax) 222: 0f b6 00 movzbl (%eax),%eax 225: 84 c0 test %al,%al 227: 75 e2 jne 20b <strcpy+0xd> ; return os; 229: 8b 45 fc mov -0x4(%ebp),%eax } 22c: c9 leave 22d: c3 ret 0000022e <strcmp>: int strcmp(const char *p, const char *q) { 22e: 55 push %ebp 22f: 89 e5 mov %esp,%ebp while(*p && *p == *q) 231: eb 08 jmp 23b <strcmp+0xd> p++, q++; 233: 83 45 08 01 addl $0x1,0x8(%ebp) 237: 83 45 0c 01 addl $0x1,0xc(%ebp) } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 23b: 8b 45 08 mov 0x8(%ebp),%eax 23e: 0f b6 00 movzbl (%eax),%eax 241: 84 c0 test %al,%al 243: 74 10 je 255 <strcmp+0x27> 245: 8b 45 08 mov 0x8(%ebp),%eax 248: 0f b6 10 movzbl (%eax),%edx 24b: 8b 45 0c mov 0xc(%ebp),%eax 24e: 0f b6 00 movzbl (%eax),%eax 251: 38 c2 cmp %al,%dl 253: 74 de je 233 <strcmp+0x5> p++, q++; return (uchar)*p - (uchar)*q; 255: 8b 45 08 mov 0x8(%ebp),%eax 258: 0f b6 00 movzbl (%eax),%eax 25b: 0f b6 d0 movzbl %al,%edx 25e: 8b 45 0c mov 0xc(%ebp),%eax 261: 0f b6 00 movzbl (%eax),%eax 264: 0f b6 c0 movzbl %al,%eax 267: 29 c2 sub %eax,%edx 269: 89 d0 mov %edx,%eax } 26b: 5d pop %ebp 26c: c3 ret 0000026d <strlen>: uint strlen(char *s) { 26d: 55 push %ebp 26e: 89 e5 mov %esp,%ebp 270: 83 ec 10 sub $0x10,%esp int n; for(n = 0; s[n]; n++) 273: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 27a: eb 04 jmp 280 <strlen+0x13> 27c: 83 45 fc 01 addl $0x1,-0x4(%ebp) 280: 8b 55 fc mov -0x4(%ebp),%edx 283: 8b 45 08 mov 0x8(%ebp),%eax 286: 01 d0 add %edx,%eax 288: 0f b6 00 movzbl (%eax),%eax 28b: 84 c0 test %al,%al 28d: 75 ed jne 27c <strlen+0xf> ; return n; 28f: 8b 45 fc mov -0x4(%ebp),%eax } 292: c9 leave 293: c3 ret 00000294 <memset>: void* memset(void *dst, int c, uint n) { 294: 55 push %ebp 295: 89 e5 mov %esp,%ebp 297: 83 ec 0c sub $0xc,%esp stosb(dst, c, n); 29a: 8b 45 10 mov 0x10(%ebp),%eax 29d: 89 44 24 08 mov %eax,0x8(%esp) 2a1: 8b 45 0c mov 0xc(%ebp),%eax 2a4: 89 44 24 04 mov %eax,0x4(%esp) 2a8: 8b 45 08 mov 0x8(%ebp),%eax 2ab: 89 04 24 mov %eax,(%esp) 2ae: e8 26 ff ff ff call 1d9 <stosb> return dst; 2b3: 8b 45 08 mov 0x8(%ebp),%eax } 2b6: c9 leave 2b7: c3 ret 000002b8 <strchr>: char* strchr(const char *s, char c) { 2b8: 55 push %ebp 2b9: 89 e5 mov %esp,%ebp 2bb: 83 ec 04 sub $0x4,%esp 2be: 8b 45 0c mov 0xc(%ebp),%eax 2c1: 88 45 fc mov %al,-0x4(%ebp) for(; *s; s++) 2c4: eb 14 jmp 2da <strchr+0x22> if(*s == c) 2c6: 8b 45 08 mov 0x8(%ebp),%eax 2c9: 0f b6 00 movzbl (%eax),%eax 2cc: 3a 45 fc cmp -0x4(%ebp),%al 2cf: 75 05 jne 2d6 <strchr+0x1e> return (char*)s; 2d1: 8b 45 08 mov 0x8(%ebp),%eax 2d4: eb 13 jmp 2e9 <strchr+0x31> } char* strchr(const char *s, char c) { for(; *s; s++) 2d6: 83 45 08 01 addl $0x1,0x8(%ebp) 2da: 8b 45 08 mov 0x8(%ebp),%eax 2dd: 0f b6 00 movzbl (%eax),%eax 2e0: 84 c0 test %al,%al 2e2: 75 e2 jne 2c6 <strchr+0xe> if(*s == c) return (char*)s; return 0; 2e4: b8 00 00 00 00 mov $0x0,%eax } 2e9: c9 leave 2ea: c3 ret 000002eb <gets>: char* gets(char *buf, int max) { 2eb: 55 push %ebp 2ec: 89 e5 mov %esp,%ebp 2ee: 83 ec 28 sub $0x28,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 2f1: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 2f8: eb 4c jmp 346 <gets+0x5b> cc = read(0, &c, 1); 2fa: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 301: 00 302: 8d 45 ef lea -0x11(%ebp),%eax 305: 89 44 24 04 mov %eax,0x4(%esp) 309: c7 04 24 00 00 00 00 movl $0x0,(%esp) 310: e8 44 01 00 00 call 459 <read> 315: 89 45 f0 mov %eax,-0x10(%ebp) if(cc < 1) 318: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 31c: 7f 02 jg 320 <gets+0x35> break; 31e: eb 31 jmp 351 <gets+0x66> buf[i++] = c; 320: 8b 45 f4 mov -0xc(%ebp),%eax 323: 8d 50 01 lea 0x1(%eax),%edx 326: 89 55 f4 mov %edx,-0xc(%ebp) 329: 89 c2 mov %eax,%edx 32b: 8b 45 08 mov 0x8(%ebp),%eax 32e: 01 c2 add %eax,%edx 330: 0f b6 45 ef movzbl -0x11(%ebp),%eax 334: 88 02 mov %al,(%edx) if(c == '\n' || c == '\r') 336: 0f b6 45 ef movzbl -0x11(%ebp),%eax 33a: 3c 0a cmp $0xa,%al 33c: 74 13 je 351 <gets+0x66> 33e: 0f b6 45 ef movzbl -0x11(%ebp),%eax 342: 3c 0d cmp $0xd,%al 344: 74 0b je 351 <gets+0x66> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 346: 8b 45 f4 mov -0xc(%ebp),%eax 349: 83 c0 01 add $0x1,%eax 34c: 3b 45 0c cmp 0xc(%ebp),%eax 34f: 7c a9 jl 2fa <gets+0xf> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 351: 8b 55 f4 mov -0xc(%ebp),%edx 354: 8b 45 08 mov 0x8(%ebp),%eax 357: 01 d0 add %edx,%eax 359: c6 00 00 movb $0x0,(%eax) return buf; 35c: 8b 45 08 mov 0x8(%ebp),%eax } 35f: c9 leave 360: c3 ret 00000361 <stat>: int stat(char *n, struct stat *st) { 361: 55 push %ebp 362: 89 e5 mov %esp,%ebp 364: 83 ec 28 sub $0x28,%esp int fd; int r; fd = open(n, O_RDONLY); 367: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 36e: 00 36f: 8b 45 08 mov 0x8(%ebp),%eax 372: 89 04 24 mov %eax,(%esp) 375: e8 07 01 00 00 call 481 <open> 37a: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0) 37d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 381: 79 07 jns 38a <stat+0x29> return -1; 383: b8 ff ff ff ff mov $0xffffffff,%eax 388: eb 23 jmp 3ad <stat+0x4c> r = fstat(fd, st); 38a: 8b 45 0c mov 0xc(%ebp),%eax 38d: 89 44 24 04 mov %eax,0x4(%esp) 391: 8b 45 f4 mov -0xc(%ebp),%eax 394: 89 04 24 mov %eax,(%esp) 397: e8 fd 00 00 00 call 499 <fstat> 39c: 89 45 f0 mov %eax,-0x10(%ebp) close(fd); 39f: 8b 45 f4 mov -0xc(%ebp),%eax 3a2: 89 04 24 mov %eax,(%esp) 3a5: e8 bf 00 00 00 call 469 <close> return r; 3aa: 8b 45 f0 mov -0x10(%ebp),%eax } 3ad: c9 leave 3ae: c3 ret 000003af <atoi>: int atoi(const char *s) { 3af: 55 push %ebp 3b0: 89 e5 mov %esp,%ebp 3b2: 83 ec 10 sub $0x10,%esp int n; n = 0; 3b5: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) while('0' <= *s && *s <= '9') 3bc: eb 25 jmp 3e3 <atoi+0x34> n = n*10 + *s++ - '0'; 3be: 8b 55 fc mov -0x4(%ebp),%edx 3c1: 89 d0 mov %edx,%eax 3c3: c1 e0 02 shl $0x2,%eax 3c6: 01 d0 add %edx,%eax 3c8: 01 c0 add %eax,%eax 3ca: 89 c1 mov %eax,%ecx 3cc: 8b 45 08 mov 0x8(%ebp),%eax 3cf: 8d 50 01 lea 0x1(%eax),%edx 3d2: 89 55 08 mov %edx,0x8(%ebp) 3d5: 0f b6 00 movzbl (%eax),%eax 3d8: 0f be c0 movsbl %al,%eax 3db: 01 c8 add %ecx,%eax 3dd: 83 e8 30 sub $0x30,%eax 3e0: 89 45 fc mov %eax,-0x4(%ebp) atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 3e3: 8b 45 08 mov 0x8(%ebp),%eax 3e6: 0f b6 00 movzbl (%eax),%eax 3e9: 3c 2f cmp $0x2f,%al 3eb: 7e 0a jle 3f7 <atoi+0x48> 3ed: 8b 45 08 mov 0x8(%ebp),%eax 3f0: 0f b6 00 movzbl (%eax),%eax 3f3: 3c 39 cmp $0x39,%al 3f5: 7e c7 jle 3be <atoi+0xf> n = n*10 + *s++ - '0'; return n; 3f7: 8b 45 fc mov -0x4(%ebp),%eax } 3fa: c9 leave 3fb: c3 ret 000003fc <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 3fc: 55 push %ebp 3fd: 89 e5 mov %esp,%ebp 3ff: 83 ec 10 sub $0x10,%esp char *dst, *src; dst = vdst; 402: 8b 45 08 mov 0x8(%ebp),%eax 405: 89 45 fc mov %eax,-0x4(%ebp) src = vsrc; 408: 8b 45 0c mov 0xc(%ebp),%eax 40b: 89 45 f8 mov %eax,-0x8(%ebp) while(n-- > 0) 40e: eb 17 jmp 427 <memmove+0x2b> *dst++ = *src++; 410: 8b 45 fc mov -0x4(%ebp),%eax 413: 8d 50 01 lea 0x1(%eax),%edx 416: 89 55 fc mov %edx,-0x4(%ebp) 419: 8b 55 f8 mov -0x8(%ebp),%edx 41c: 8d 4a 01 lea 0x1(%edx),%ecx 41f: 89 4d f8 mov %ecx,-0x8(%ebp) 422: 0f b6 12 movzbl (%edx),%edx 425: 88 10 mov %dl,(%eax) { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 427: 8b 45 10 mov 0x10(%ebp),%eax 42a: 8d 50 ff lea -0x1(%eax),%edx 42d: 89 55 10 mov %edx,0x10(%ebp) 430: 85 c0 test %eax,%eax 432: 7f dc jg 410 <memmove+0x14> *dst++ = *src++; return vdst; 434: 8b 45 08 mov 0x8(%ebp),%eax } 437: c9 leave 438: c3 ret 00000439 <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 439: b8 01 00 00 00 mov $0x1,%eax 43e: cd 40 int $0x40 440: c3 ret 00000441 <exit>: SYSCALL(exit) 441: b8 02 00 00 00 mov $0x2,%eax 446: cd 40 int $0x40 448: c3 ret 00000449 <wait>: SYSCALL(wait) 449: b8 03 00 00 00 mov $0x3,%eax 44e: cd 40 int $0x40 450: c3 ret 00000451 <pipe>: SYSCALL(pipe) 451: b8 04 00 00 00 mov $0x4,%eax 456: cd 40 int $0x40 458: c3 ret 00000459 <read>: SYSCALL(read) 459: b8 05 00 00 00 mov $0x5,%eax 45e: cd 40 int $0x40 460: c3 ret 00000461 <write>: SYSCALL(write) 461: b8 10 00 00 00 mov $0x10,%eax 466: cd 40 int $0x40 468: c3 ret 00000469 <close>: SYSCALL(close) 469: b8 15 00 00 00 mov $0x15,%eax 46e: cd 40 int $0x40 470: c3 ret 00000471 <kill>: SYSCALL(kill) 471: b8 06 00 00 00 mov $0x6,%eax 476: cd 40 int $0x40 478: c3 ret 00000479 <exec>: SYSCALL(exec) 479: b8 07 00 00 00 mov $0x7,%eax 47e: cd 40 int $0x40 480: c3 ret 00000481 <open>: SYSCALL(open) 481: b8 0f 00 00 00 mov $0xf,%eax 486: cd 40 int $0x40 488: c3 ret 00000489 <mknod>: SYSCALL(mknod) 489: b8 11 00 00 00 mov $0x11,%eax 48e: cd 40 int $0x40 490: c3 ret 00000491 <unlink>: SYSCALL(unlink) 491: b8 12 00 00 00 mov $0x12,%eax 496: cd 40 int $0x40 498: c3 ret 00000499 <fstat>: SYSCALL(fstat) 499: b8 08 00 00 00 mov $0x8,%eax 49e: cd 40 int $0x40 4a0: c3 ret 000004a1 <link>: SYSCALL(link) 4a1: b8 13 00 00 00 mov $0x13,%eax 4a6: cd 40 int $0x40 4a8: c3 ret 000004a9 <mkdir>: SYSCALL(mkdir) 4a9: b8 14 00 00 00 mov $0x14,%eax 4ae: cd 40 int $0x40 4b0: c3 ret 000004b1 <chdir>: SYSCALL(chdir) 4b1: b8 09 00 00 00 mov $0x9,%eax 4b6: cd 40 int $0x40 4b8: c3 ret 000004b9 <dup>: SYSCALL(dup) 4b9: b8 0a 00 00 00 mov $0xa,%eax 4be: cd 40 int $0x40 4c0: c3 ret 000004c1 <getpid>: SYSCALL(getpid) 4c1: b8 0b 00 00 00 mov $0xb,%eax 4c6: cd 40 int $0x40 4c8: c3 ret 000004c9 <sbrk>: SYSCALL(sbrk) 4c9: b8 0c 00 00 00 mov $0xc,%eax 4ce: cd 40 int $0x40 4d0: c3 ret 000004d1 <sleep>: SYSCALL(sleep) 4d1: b8 0d 00 00 00 mov $0xd,%eax 4d6: cd 40 int $0x40 4d8: c3 ret 000004d9 <uptime>: SYSCALL(uptime) 4d9: b8 0e 00 00 00 mov $0xe,%eax 4de: cd 40 int $0x40 4e0: c3 ret 000004e1 <changepriority>: SYSCALL(changepriority) 4e1: b8 16 00 00 00 mov $0x16,%eax 4e6: cd 40 int $0x40 4e8: c3 ret 000004e9 <processstatus>: SYSCALL(processstatus) 4e9: b8 17 00 00 00 mov $0x17,%eax 4ee: cd 40 int $0x40 4f0: c3 ret 000004f1 <randomgen>: SYSCALL(randomgen) 4f1: b8 18 00 00 00 mov $0x18,%eax 4f6: cd 40 int $0x40 4f8: c3 ret 000004f9 <randomgenrange>: SYSCALL(randomgenrange) 4f9: b8 19 00 00 00 mov $0x19,%eax 4fe: cd 40 int $0x40 500: c3 ret 00000501 <putc>: #include "stat.h" #include "user.h" static void putc(int fd, char c) { 501: 55 push %ebp 502: 89 e5 mov %esp,%ebp 504: 83 ec 18 sub $0x18,%esp 507: 8b 45 0c mov 0xc(%ebp),%eax 50a: 88 45 f4 mov %al,-0xc(%ebp) write(fd, &c, 1); 50d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 514: 00 515: 8d 45 f4 lea -0xc(%ebp),%eax 518: 89 44 24 04 mov %eax,0x4(%esp) 51c: 8b 45 08 mov 0x8(%ebp),%eax 51f: 89 04 24 mov %eax,(%esp) 522: e8 3a ff ff ff call 461 <write> } 527: c9 leave 528: c3 ret 00000529 <printint>: static void printint(int fd, int xx, int base, int sgn) { 529: 55 push %ebp 52a: 89 e5 mov %esp,%ebp 52c: 56 push %esi 52d: 53 push %ebx 52e: 83 ec 30 sub $0x30,%esp static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 531: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) if(sgn && xx < 0){ 538: 83 7d 14 00 cmpl $0x0,0x14(%ebp) 53c: 74 17 je 555 <printint+0x2c> 53e: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 542: 79 11 jns 555 <printint+0x2c> neg = 1; 544: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) x = -xx; 54b: 8b 45 0c mov 0xc(%ebp),%eax 54e: f7 d8 neg %eax 550: 89 45 ec mov %eax,-0x14(%ebp) 553: eb 06 jmp 55b <printint+0x32> } else { x = xx; 555: 8b 45 0c mov 0xc(%ebp),%eax 558: 89 45 ec mov %eax,-0x14(%ebp) } i = 0; 55b: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) do{ buf[i++] = digits[x % base]; 562: 8b 4d f4 mov -0xc(%ebp),%ecx 565: 8d 41 01 lea 0x1(%ecx),%eax 568: 89 45 f4 mov %eax,-0xc(%ebp) 56b: 8b 5d 10 mov 0x10(%ebp),%ebx 56e: 8b 45 ec mov -0x14(%ebp),%eax 571: ba 00 00 00 00 mov $0x0,%edx 576: f7 f3 div %ebx 578: 89 d0 mov %edx,%eax 57a: 0f b6 80 50 0c 00 00 movzbl 0xc50(%eax),%eax 581: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1) }while((x /= base) != 0); 585: 8b 75 10 mov 0x10(%ebp),%esi 588: 8b 45 ec mov -0x14(%ebp),%eax 58b: ba 00 00 00 00 mov $0x0,%edx 590: f7 f6 div %esi 592: 89 45 ec mov %eax,-0x14(%ebp) 595: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 599: 75 c7 jne 562 <printint+0x39> if(neg) 59b: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 59f: 74 10 je 5b1 <printint+0x88> buf[i++] = '-'; 5a1: 8b 45 f4 mov -0xc(%ebp),%eax 5a4: 8d 50 01 lea 0x1(%eax),%edx 5a7: 89 55 f4 mov %edx,-0xc(%ebp) 5aa: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1) while(--i >= 0) 5af: eb 1f jmp 5d0 <printint+0xa7> 5b1: eb 1d jmp 5d0 <printint+0xa7> putc(fd, buf[i]); 5b3: 8d 55 dc lea -0x24(%ebp),%edx 5b6: 8b 45 f4 mov -0xc(%ebp),%eax 5b9: 01 d0 add %edx,%eax 5bb: 0f b6 00 movzbl (%eax),%eax 5be: 0f be c0 movsbl %al,%eax 5c1: 89 44 24 04 mov %eax,0x4(%esp) 5c5: 8b 45 08 mov 0x8(%ebp),%eax 5c8: 89 04 24 mov %eax,(%esp) 5cb: e8 31 ff ff ff call 501 <putc> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 5d0: 83 6d f4 01 subl $0x1,-0xc(%ebp) 5d4: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 5d8: 79 d9 jns 5b3 <printint+0x8a> putc(fd, buf[i]); } 5da: 83 c4 30 add $0x30,%esp 5dd: 5b pop %ebx 5de: 5e pop %esi 5df: 5d pop %ebp 5e0: c3 ret 000005e1 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 5e1: 55 push %ebp 5e2: 89 e5 mov %esp,%ebp 5e4: 83 ec 38 sub $0x38,%esp char *s; int c, i, state; uint *ap; state = 0; 5e7: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) ap = (uint*)(void*)&fmt + 1; 5ee: 8d 45 0c lea 0xc(%ebp),%eax 5f1: 83 c0 04 add $0x4,%eax 5f4: 89 45 e8 mov %eax,-0x18(%ebp) for(i = 0; fmt[i]; i++){ 5f7: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 5fe: e9 7c 01 00 00 jmp 77f <printf+0x19e> c = fmt[i] & 0xff; 603: 8b 55 0c mov 0xc(%ebp),%edx 606: 8b 45 f0 mov -0x10(%ebp),%eax 609: 01 d0 add %edx,%eax 60b: 0f b6 00 movzbl (%eax),%eax 60e: 0f be c0 movsbl %al,%eax 611: 25 ff 00 00 00 and $0xff,%eax 616: 89 45 e4 mov %eax,-0x1c(%ebp) if(state == 0){ 619: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 61d: 75 2c jne 64b <printf+0x6a> if(c == '%'){ 61f: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 623: 75 0c jne 631 <printf+0x50> state = '%'; 625: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp) 62c: e9 4a 01 00 00 jmp 77b <printf+0x19a> } else { putc(fd, c); 631: 8b 45 e4 mov -0x1c(%ebp),%eax 634: 0f be c0 movsbl %al,%eax 637: 89 44 24 04 mov %eax,0x4(%esp) 63b: 8b 45 08 mov 0x8(%ebp),%eax 63e: 89 04 24 mov %eax,(%esp) 641: e8 bb fe ff ff call 501 <putc> 646: e9 30 01 00 00 jmp 77b <printf+0x19a> } } else if(state == '%'){ 64b: 83 7d ec 25 cmpl $0x25,-0x14(%ebp) 64f: 0f 85 26 01 00 00 jne 77b <printf+0x19a> if(c == 'd'){ 655: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp) 659: 75 2d jne 688 <printf+0xa7> printint(fd, *ap, 10, 1); 65b: 8b 45 e8 mov -0x18(%ebp),%eax 65e: 8b 00 mov (%eax),%eax 660: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp) 667: 00 668: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) 66f: 00 670: 89 44 24 04 mov %eax,0x4(%esp) 674: 8b 45 08 mov 0x8(%ebp),%eax 677: 89 04 24 mov %eax,(%esp) 67a: e8 aa fe ff ff call 529 <printint> ap++; 67f: 83 45 e8 04 addl $0x4,-0x18(%ebp) 683: e9 ec 00 00 00 jmp 774 <printf+0x193> } else if(c == 'x' || c == 'p'){ 688: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp) 68c: 74 06 je 694 <printf+0xb3> 68e: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp) 692: 75 2d jne 6c1 <printf+0xe0> printint(fd, *ap, 16, 0); 694: 8b 45 e8 mov -0x18(%ebp),%eax 697: 8b 00 mov (%eax),%eax 699: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) 6a0: 00 6a1: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 6a8: 00 6a9: 89 44 24 04 mov %eax,0x4(%esp) 6ad: 8b 45 08 mov 0x8(%ebp),%eax 6b0: 89 04 24 mov %eax,(%esp) 6b3: e8 71 fe ff ff call 529 <printint> ap++; 6b8: 83 45 e8 04 addl $0x4,-0x18(%ebp) 6bc: e9 b3 00 00 00 jmp 774 <printf+0x193> } else if(c == 's'){ 6c1: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp) 6c5: 75 45 jne 70c <printf+0x12b> s = (char*)*ap; 6c7: 8b 45 e8 mov -0x18(%ebp),%eax 6ca: 8b 00 mov (%eax),%eax 6cc: 89 45 f4 mov %eax,-0xc(%ebp) ap++; 6cf: 83 45 e8 04 addl $0x4,-0x18(%ebp) if(s == 0) 6d3: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 6d7: 75 09 jne 6e2 <printf+0x101> s = "(null)"; 6d9: c7 45 f4 e5 09 00 00 movl $0x9e5,-0xc(%ebp) while(*s != 0){ 6e0: eb 1e jmp 700 <printf+0x11f> 6e2: eb 1c jmp 700 <printf+0x11f> putc(fd, *s); 6e4: 8b 45 f4 mov -0xc(%ebp),%eax 6e7: 0f b6 00 movzbl (%eax),%eax 6ea: 0f be c0 movsbl %al,%eax 6ed: 89 44 24 04 mov %eax,0x4(%esp) 6f1: 8b 45 08 mov 0x8(%ebp),%eax 6f4: 89 04 24 mov %eax,(%esp) 6f7: e8 05 fe ff ff call 501 <putc> s++; 6fc: 83 45 f4 01 addl $0x1,-0xc(%ebp) } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 700: 8b 45 f4 mov -0xc(%ebp),%eax 703: 0f b6 00 movzbl (%eax),%eax 706: 84 c0 test %al,%al 708: 75 da jne 6e4 <printf+0x103> 70a: eb 68 jmp 774 <printf+0x193> putc(fd, *s); s++; } } else if(c == 'c'){ 70c: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp) 710: 75 1d jne 72f <printf+0x14e> putc(fd, *ap); 712: 8b 45 e8 mov -0x18(%ebp),%eax 715: 8b 00 mov (%eax),%eax 717: 0f be c0 movsbl %al,%eax 71a: 89 44 24 04 mov %eax,0x4(%esp) 71e: 8b 45 08 mov 0x8(%ebp),%eax 721: 89 04 24 mov %eax,(%esp) 724: e8 d8 fd ff ff call 501 <putc> ap++; 729: 83 45 e8 04 addl $0x4,-0x18(%ebp) 72d: eb 45 jmp 774 <printf+0x193> } else if(c == '%'){ 72f: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 733: 75 17 jne 74c <printf+0x16b> putc(fd, c); 735: 8b 45 e4 mov -0x1c(%ebp),%eax 738: 0f be c0 movsbl %al,%eax 73b: 89 44 24 04 mov %eax,0x4(%esp) 73f: 8b 45 08 mov 0x8(%ebp),%eax 742: 89 04 24 mov %eax,(%esp) 745: e8 b7 fd ff ff call 501 <putc> 74a: eb 28 jmp 774 <printf+0x193> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 74c: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp) 753: 00 754: 8b 45 08 mov 0x8(%ebp),%eax 757: 89 04 24 mov %eax,(%esp) 75a: e8 a2 fd ff ff call 501 <putc> putc(fd, c); 75f: 8b 45 e4 mov -0x1c(%ebp),%eax 762: 0f be c0 movsbl %al,%eax 765: 89 44 24 04 mov %eax,0x4(%esp) 769: 8b 45 08 mov 0x8(%ebp),%eax 76c: 89 04 24 mov %eax,(%esp) 76f: e8 8d fd ff ff call 501 <putc> } state = 0; 774: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 77b: 83 45 f0 01 addl $0x1,-0x10(%ebp) 77f: 8b 55 0c mov 0xc(%ebp),%edx 782: 8b 45 f0 mov -0x10(%ebp),%eax 785: 01 d0 add %edx,%eax 787: 0f b6 00 movzbl (%eax),%eax 78a: 84 c0 test %al,%al 78c: 0f 85 71 fe ff ff jne 603 <printf+0x22> putc(fd, c); } state = 0; } } } 792: c9 leave 793: c3 ret 00000794 <free>: static Header base; static Header *freep; void free(void *ap) { 794: 55 push %ebp 795: 89 e5 mov %esp,%ebp 797: 83 ec 10 sub $0x10,%esp Header *bp, *p; bp = (Header*)ap - 1; 79a: 8b 45 08 mov 0x8(%ebp),%eax 79d: 83 e8 08 sub $0x8,%eax 7a0: 89 45 f8 mov %eax,-0x8(%ebp) for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 7a3: a1 88 0c 00 00 mov 0xc88,%eax 7a8: 89 45 fc mov %eax,-0x4(%ebp) 7ab: eb 24 jmp 7d1 <free+0x3d> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 7ad: 8b 45 fc mov -0x4(%ebp),%eax 7b0: 8b 00 mov (%eax),%eax 7b2: 3b 45 fc cmp -0x4(%ebp),%eax 7b5: 77 12 ja 7c9 <free+0x35> 7b7: 8b 45 f8 mov -0x8(%ebp),%eax 7ba: 3b 45 fc cmp -0x4(%ebp),%eax 7bd: 77 24 ja 7e3 <free+0x4f> 7bf: 8b 45 fc mov -0x4(%ebp),%eax 7c2: 8b 00 mov (%eax),%eax 7c4: 3b 45 f8 cmp -0x8(%ebp),%eax 7c7: 77 1a ja 7e3 <free+0x4f> free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 7c9: 8b 45 fc mov -0x4(%ebp),%eax 7cc: 8b 00 mov (%eax),%eax 7ce: 89 45 fc mov %eax,-0x4(%ebp) 7d1: 8b 45 f8 mov -0x8(%ebp),%eax 7d4: 3b 45 fc cmp -0x4(%ebp),%eax 7d7: 76 d4 jbe 7ad <free+0x19> 7d9: 8b 45 fc mov -0x4(%ebp),%eax 7dc: 8b 00 mov (%eax),%eax 7de: 3b 45 f8 cmp -0x8(%ebp),%eax 7e1: 76 ca jbe 7ad <free+0x19> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ 7e3: 8b 45 f8 mov -0x8(%ebp),%eax 7e6: 8b 40 04 mov 0x4(%eax),%eax 7e9: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 7f0: 8b 45 f8 mov -0x8(%ebp),%eax 7f3: 01 c2 add %eax,%edx 7f5: 8b 45 fc mov -0x4(%ebp),%eax 7f8: 8b 00 mov (%eax),%eax 7fa: 39 c2 cmp %eax,%edx 7fc: 75 24 jne 822 <free+0x8e> bp->s.size += p->s.ptr->s.size; 7fe: 8b 45 f8 mov -0x8(%ebp),%eax 801: 8b 50 04 mov 0x4(%eax),%edx 804: 8b 45 fc mov -0x4(%ebp),%eax 807: 8b 00 mov (%eax),%eax 809: 8b 40 04 mov 0x4(%eax),%eax 80c: 01 c2 add %eax,%edx 80e: 8b 45 f8 mov -0x8(%ebp),%eax 811: 89 50 04 mov %edx,0x4(%eax) bp->s.ptr = p->s.ptr->s.ptr; 814: 8b 45 fc mov -0x4(%ebp),%eax 817: 8b 00 mov (%eax),%eax 819: 8b 10 mov (%eax),%edx 81b: 8b 45 f8 mov -0x8(%ebp),%eax 81e: 89 10 mov %edx,(%eax) 820: eb 0a jmp 82c <free+0x98> } else bp->s.ptr = p->s.ptr; 822: 8b 45 fc mov -0x4(%ebp),%eax 825: 8b 10 mov (%eax),%edx 827: 8b 45 f8 mov -0x8(%ebp),%eax 82a: 89 10 mov %edx,(%eax) if(p + p->s.size == bp){ 82c: 8b 45 fc mov -0x4(%ebp),%eax 82f: 8b 40 04 mov 0x4(%eax),%eax 832: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 839: 8b 45 fc mov -0x4(%ebp),%eax 83c: 01 d0 add %edx,%eax 83e: 3b 45 f8 cmp -0x8(%ebp),%eax 841: 75 20 jne 863 <free+0xcf> p->s.size += bp->s.size; 843: 8b 45 fc mov -0x4(%ebp),%eax 846: 8b 50 04 mov 0x4(%eax),%edx 849: 8b 45 f8 mov -0x8(%ebp),%eax 84c: 8b 40 04 mov 0x4(%eax),%eax 84f: 01 c2 add %eax,%edx 851: 8b 45 fc mov -0x4(%ebp),%eax 854: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 857: 8b 45 f8 mov -0x8(%ebp),%eax 85a: 8b 10 mov (%eax),%edx 85c: 8b 45 fc mov -0x4(%ebp),%eax 85f: 89 10 mov %edx,(%eax) 861: eb 08 jmp 86b <free+0xd7> } else p->s.ptr = bp; 863: 8b 45 fc mov -0x4(%ebp),%eax 866: 8b 55 f8 mov -0x8(%ebp),%edx 869: 89 10 mov %edx,(%eax) freep = p; 86b: 8b 45 fc mov -0x4(%ebp),%eax 86e: a3 88 0c 00 00 mov %eax,0xc88 } 873: c9 leave 874: c3 ret 00000875 <morecore>: static Header* morecore(uint nu) { 875: 55 push %ebp 876: 89 e5 mov %esp,%ebp 878: 83 ec 28 sub $0x28,%esp char *p; Header *hp; if(nu < 4096) 87b: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp) 882: 77 07 ja 88b <morecore+0x16> nu = 4096; 884: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp) p = sbrk(nu * sizeof(Header)); 88b: 8b 45 08 mov 0x8(%ebp),%eax 88e: c1 e0 03 shl $0x3,%eax 891: 89 04 24 mov %eax,(%esp) 894: e8 30 fc ff ff call 4c9 <sbrk> 899: 89 45 f4 mov %eax,-0xc(%ebp) if(p == (char*)-1) 89c: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) 8a0: 75 07 jne 8a9 <morecore+0x34> return 0; 8a2: b8 00 00 00 00 mov $0x0,%eax 8a7: eb 22 jmp 8cb <morecore+0x56> hp = (Header*)p; 8a9: 8b 45 f4 mov -0xc(%ebp),%eax 8ac: 89 45 f0 mov %eax,-0x10(%ebp) hp->s.size = nu; 8af: 8b 45 f0 mov -0x10(%ebp),%eax 8b2: 8b 55 08 mov 0x8(%ebp),%edx 8b5: 89 50 04 mov %edx,0x4(%eax) free((void*)(hp + 1)); 8b8: 8b 45 f0 mov -0x10(%ebp),%eax 8bb: 83 c0 08 add $0x8,%eax 8be: 89 04 24 mov %eax,(%esp) 8c1: e8 ce fe ff ff call 794 <free> return freep; 8c6: a1 88 0c 00 00 mov 0xc88,%eax } 8cb: c9 leave 8cc: c3 ret 000008cd <malloc>: void* malloc(uint nbytes) { 8cd: 55 push %ebp 8ce: 89 e5 mov %esp,%ebp 8d0: 83 ec 28 sub $0x28,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 8d3: 8b 45 08 mov 0x8(%ebp),%eax 8d6: 83 c0 07 add $0x7,%eax 8d9: c1 e8 03 shr $0x3,%eax 8dc: 83 c0 01 add $0x1,%eax 8df: 89 45 ec mov %eax,-0x14(%ebp) if((prevp = freep) == 0){ 8e2: a1 88 0c 00 00 mov 0xc88,%eax 8e7: 89 45 f0 mov %eax,-0x10(%ebp) 8ea: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 8ee: 75 23 jne 913 <malloc+0x46> base.s.ptr = freep = prevp = &base; 8f0: c7 45 f0 80 0c 00 00 movl $0xc80,-0x10(%ebp) 8f7: 8b 45 f0 mov -0x10(%ebp),%eax 8fa: a3 88 0c 00 00 mov %eax,0xc88 8ff: a1 88 0c 00 00 mov 0xc88,%eax 904: a3 80 0c 00 00 mov %eax,0xc80 base.s.size = 0; 909: c7 05 84 0c 00 00 00 movl $0x0,0xc84 910: 00 00 00 } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 913: 8b 45 f0 mov -0x10(%ebp),%eax 916: 8b 00 mov (%eax),%eax 918: 89 45 f4 mov %eax,-0xc(%ebp) if(p->s.size >= nunits){ 91b: 8b 45 f4 mov -0xc(%ebp),%eax 91e: 8b 40 04 mov 0x4(%eax),%eax 921: 3b 45 ec cmp -0x14(%ebp),%eax 924: 72 4d jb 973 <malloc+0xa6> if(p->s.size == nunits) 926: 8b 45 f4 mov -0xc(%ebp),%eax 929: 8b 40 04 mov 0x4(%eax),%eax 92c: 3b 45 ec cmp -0x14(%ebp),%eax 92f: 75 0c jne 93d <malloc+0x70> prevp->s.ptr = p->s.ptr; 931: 8b 45 f4 mov -0xc(%ebp),%eax 934: 8b 10 mov (%eax),%edx 936: 8b 45 f0 mov -0x10(%ebp),%eax 939: 89 10 mov %edx,(%eax) 93b: eb 26 jmp 963 <malloc+0x96> else { p->s.size -= nunits; 93d: 8b 45 f4 mov -0xc(%ebp),%eax 940: 8b 40 04 mov 0x4(%eax),%eax 943: 2b 45 ec sub -0x14(%ebp),%eax 946: 89 c2 mov %eax,%edx 948: 8b 45 f4 mov -0xc(%ebp),%eax 94b: 89 50 04 mov %edx,0x4(%eax) p += p->s.size; 94e: 8b 45 f4 mov -0xc(%ebp),%eax 951: 8b 40 04 mov 0x4(%eax),%eax 954: c1 e0 03 shl $0x3,%eax 957: 01 45 f4 add %eax,-0xc(%ebp) p->s.size = nunits; 95a: 8b 45 f4 mov -0xc(%ebp),%eax 95d: 8b 55 ec mov -0x14(%ebp),%edx 960: 89 50 04 mov %edx,0x4(%eax) } freep = prevp; 963: 8b 45 f0 mov -0x10(%ebp),%eax 966: a3 88 0c 00 00 mov %eax,0xc88 return (void*)(p + 1); 96b: 8b 45 f4 mov -0xc(%ebp),%eax 96e: 83 c0 08 add $0x8,%eax 971: eb 38 jmp 9ab <malloc+0xde> } if(p == freep) 973: a1 88 0c 00 00 mov 0xc88,%eax 978: 39 45 f4 cmp %eax,-0xc(%ebp) 97b: 75 1b jne 998 <malloc+0xcb> if((p = morecore(nunits)) == 0) 97d: 8b 45 ec mov -0x14(%ebp),%eax 980: 89 04 24 mov %eax,(%esp) 983: e8 ed fe ff ff call 875 <morecore> 988: 89 45 f4 mov %eax,-0xc(%ebp) 98b: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 98f: 75 07 jne 998 <malloc+0xcb> return 0; 991: b8 00 00 00 00 mov $0x0,%eax 996: eb 13 jmp 9ab <malloc+0xde> nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 998: 8b 45 f4 mov -0xc(%ebp),%eax 99b: 89 45 f0 mov %eax,-0x10(%ebp) 99e: 8b 45 f4 mov -0xc(%ebp),%eax 9a1: 8b 00 mov (%eax),%eax 9a3: 89 45 f4 mov %eax,-0xc(%ebp) return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } 9a6: e9 70 ff ff ff jmp 91b <malloc+0x4e> } 9ab: c9 leave 9ac: c3 ret
#include <cmath> #include <iostream> #include <fstream> #include <iterator> #include <string> #include <iomanip> #include "de2d.h" double Omega(const Vector2D & rM, const Vector2D & rN, const Vector2D nN) { Vector2D rNM = rM - rN; Vector2D gradPhi = (0.5/M_PI/pow(rNM.module(),2.0))*rNM; return dotProd(gradPhi,nN); } double dl(const Segm2D & S) { return (S.B-S.A).module(); } Vector2D normal(const Segm2D & S) { Vector2D r12 = S.B - S.A; Vector2D n = Vector2D( -r12.y, r12.x ); return (1.0/n.module())*n; } double phi0(const Vector2D & rM, const double & q1, const Vector2D & r1) { return .5*q1*M_1_PI*log((rM-r1).module()); } Vector2D v0(const Vector2D & rM, const double & q1, const Vector2D & r1) { Vector2D r = rM - r1; return .5*q1*M_1_PI*r/pow(r.module(),2.0); } Vector2D vVortex(const Vector2D & rM, const Vector2D & A) { if(rM==A) return Vector2D(0.0,0.0); double r = (rM-A).module(); double dPsi2x = 0.5/M_PI*(rM.x-A.x)/pow(r,2.0); double dPsi2y = 0.5/M_PI*(rM.y-A.y)/pow(r,2.0); return Vector2D(dPsi2y,-dPsi2x); } double Theta(const Vector2D & rM, const Vector2D & A, const double & VEps){ if(rM==A) return 0.0; Vector2D rAM = rM - A ; double r = rAM.module(); double koeff = 1.0; if(r<VEps) koeff = (63*pow(r/VEps,5.0)-90*pow(r/VEps,7.0)+35*pow(r/VEps,9.0))/8.0; return koeff; } Vector2D vSegmTheta(const Vector2D & rM, const Segm2D & s, const double & VEps) { return vVortexTheta(rM,s.A,VEps)-vVortexTheta(rM,s.B,VEps); } Vector2D vVortexTheta(const Vector2D & rM, const Vector2D & A, const double & VEps){ if(rM==A) return Vector2D(0.0,0.0); double r = (rM-A).module(); double dPsi2x = 0.5/M_PI*(rM.x-A.x)/pow(r,2.0); double dPsi2y = 0.5/M_PI*(rM.y-A.y)/pow(r,2.0); double koeff = Theta(rM,A,VEps); return koeff*Vector2D(dPsi2y,-dPsi2x); } void save_border(const std::vector<Segm2D> & f, const std::string & s) { std::ofstream file(s.c_str()); size_t n = f.size(); std::copy ( f.begin(), f.end(), std::ostream_iterator<Segm2D>(file,"\n") ); } void load_border(std::vector<Segm2D> & f, const std::string & s) { std::ifstream file(s.c_str()); std::istream_iterator<Segm2D> is(file), eof; std::copy(is, eof, std::back_inserter(f) ); }
; ; ANSI Video handling for the MSX ; ; Handles colors ; ; Scrollup ; ; Stefano Bodrato - Sept. 2017 ; ; $Id: f_ansi_scrollup_nobios.asm $ ; SECTION code_clib PUBLIC ansi_SCROLLUP PUBLIC __tms9918_scroll_buffer EXTERN __tms9918_attribute EXTERN CONSOLE_ROWS EXTERN LDIRVM EXTERN LDIRMV EXTERN FILVRM .ansi_SCROLLUP push ix ld b,CONSOLE_ROWS-1 ld hl,256 .scloop push bc push hl ld de,__tms9918_scroll_buffer ld bc,256 call LDIRMV pop hl push hl ld de,-256 add hl,de ld de,__tms9918_scroll_buffer ld bc,256 ex de,hl call LDIRVM pop hl push hl ld de,8192 add hl,de push hl ld de,__tms9918_scroll_buffer ld bc,256 call LDIRMV pop hl ld de,-256 add hl,de ld de,__tms9918_scroll_buffer ld bc,256 ex de,hl call LDIRVM pop hl inc h pop bc djnz scloop dec h xor a ld bc,256 call FILVRM pop ix ret SECTION bss_clib .__tms9918_scroll_buffer defs 256
TITLE PRNVALFP - Print floaing point values page 56,132 ;*** ; PRNVALFP - Print values ; ; Copyright <C> 1986, Microsoft Corporation ; ;Purpose: ; ; This module contains B$P<term><type> for floating point ; ; The PRINT, WRITE, and LPRINT statements have a large number of ; runtime calls that can be generated, based on the list of ; expressions given. There is a unique preamble call for each such ; statement (except PRINT), to correctly set up flags, vectors, etc. ; The actual printing call itself is one of 15 possibilities, based ; on the argument type, and one of three possible ways of terminating ; the print: ',', ';', or EOL. Each of these 15 calls is in the ; form B$P<term><type> where <term> specifies the print termination ; method, and <type> specifies the type of the argument. ; ; <term>: ; C == ',' (i.e., something like 'PRINT X,' was specified) ; S == ';' ; E == EOL (neither ',' nor ';' was specified) ; ; <type>: ; R4 == single precision real ; R8 == double precision real ; CY == currency ; ; Thus, for example, a call to B$PER4 would be used to print a s.p. ; value and terminate with a EOL. ; ; The list of expressions can be of any size; for each additional ; expression, another one of the fifteen possible runtime calls is ; generated. After the last such expression, a call to B$PEOS is ; generated (if not terminated with EOL). If no expression is ; specified, a NULL string is printed, so 'PRINT' would generate a ; call to B$PESD with a null string as the parameter (print a string, ; terminate with EOL). ; ;****************************************************************************** INCLUDE switch.inc INCLUDE rmacros.inc useSeg DK_TEXT INCLUDE seg.inc INCLUDE rtps.inc SUBTTL local constant definitions page COMA EQU 0 ;comma SEMI EQU 1 ;semicolumn EOL EQU 2 ;forced EOL externFP B$PRINT ;Common Print routine assumes CS,DK_TEXT sBegin DK_TEXT externNP B$FloatCONASC ;Pull in floating point conversion routines SUBTTL print interfaces -- B$P<term><type>(<param>) page ;*** ; B$P<term><type>(<param>) -- print an item for : ; PRINT, PRINT #, PRINT USING, PRINT # USING, ; WRITE, WRITE #, ; LPRINT, LPRINT USING. ; ;Purpose: ; These are interfaces to the compiler. Each entry point sets up ; (1) types of value & terminator, and ; (2) a pointer to that item, ; and then fall through PRINT, which performs actual printing job. ; ; <term>, <type> & <param> may vary as follows: ; <term>: ; C: Comma used as terminator ; S: Semi used as terminator ; E: End of statement used as terminator ; <type>: ; R4: Single precision real (sp) ; R8: Double precision real (dp) ; CY: Currency ; <param>: ; A parameter of type <type> to be printed. ; ; ;Entry: ; Parameter was pushed in stack. ; <type> Val = Number if <type> is numerical type ; ;Exit: ; through B$PRINT ;Uses: ; none ;Exceptions: ; ;******************************************************************************* ;======================== ; Print R4, | ;======================== cProc B$PCR4,<PUBLIC,FAR> cBegin nogen ;no stack frame generated MOV AX,COMA SHL 8 + VT_R4 ;AX=[terminator type | value type] JMP B$PRINT ;print the item cEnd nogen ;no code generated ;======================== ; Print R4; | ;======================== cProc B$PSR4,<PUBLIC,FAR> cBegin nogen ;no stack frame generated MOV AX,SEMI SHL 8 + VT_R4 ;AX=[terminator type | value type] JMP B$PRINT ;print the item cEnd nogen ;no code generated ;======================== ; Print R4 | ;======================== cProc B$PER4,<PUBLIC,FAR> cBegin nogen ;no stack frame generated MOV AX,EOL SHL 8 + VT_R4 ;AX=[terminator type | value type] JMP B$PRINT ;print the item cEnd nogen ;no code generated ;======================== ; Print R8, | ;======================== cProc B$PCR8,<PUBLIC,FAR> cBegin nogen ;no stack frame generated MOV AX,COMA SHL 8 + VT_R8 ;AX=[terminator type | value type] JMP B$PRINT ;print the item cEnd nogen ;no code generated ;======================== ; Print R8; | ;======================== cProc B$PSR8,<PUBLIC,FAR> cBegin nogen ;no stack frame generated MOV AX,SEMI SHL 8 + VT_R8 ;AX=[terminator type | value type] JMP B$PRINT ;print the item cEnd nogen ;no code generated ;======================== ; Print R8 | ;======================== cProc B$PER8,<PUBLIC,FAR> cBegin nogen ;no stack frame generated MOV AX,EOL SHL 8 + VT_R8 ;AX=[terminator type | value type] JMP B$PRINT ;print the item cEnd nogen ;no code generated sEnd DK_TEXT END
; A102560: Expansion of (1-x^3)/(1-x^4). ; 1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1,1,0,0,-1 mod $0,4 mov $2,$0 gcd $0,2 sub $0,$2 div $0,2
; A079757: Periodic sequence 1 0 -2 3 -2 0,... ; 1,0,-2,3,-2,0,1,0,-2,3,-2,0,1,0,-2,3,-2,0,1,0,-2,3,-2,0,1,0,-2,3,-2,0,1,0,-2,3,-2,0,1,0,-2,3,-2,0,1,0,-2,3,-2,0,1,0,-2,3,-2,0,1,0,-2,3,-2,0,1,0,-2,3,-2,0,1,0,-2,3,-2,0,1,0,-2,3,-2,0,1,0,-2,3,-2,0,1,0,-2,3,-2,0 pow $0,2 mov $2,$0 add $2,2 add $0,$2 div $0,3 sub $0,1 mov $1,1 mov $3,7 lpb $0,1 sub $0,$3 sub $0,1 lpe sub $1,$0 sub $1,1
; all the enemies include "enemyData.inc" ENEMY_CONFIGURATIONFLAG_RANDOM_JUMPING = $80 ENEMY_CONFIGURATIONFLAG_GRAVITY = $40 ENEMY_CONFIGURATIONFLAG_FLOOR_HANDLING = $20 ENEMY_CONFIGURATIONFLAG_XMOVEMENT = $10 ENEMY_CONFIGURATIONFLAG_XMOVEMENT_HALVE_SPEED = $08 ENEMY_CONFIGURATIONFLAG_COLLISION_JUMPING = $04 ENEMY_CONFIGURATIONFLAG_PERIODICAL_SHOT = $02 ENEMY_CONFIGURATIONFLAG_EXPLODE_ON_COLLISION = $01 ENEMY_ANIMTYPE_SLOWER1 = %10000000 ENEMY_ANIMTYPE_SLOWER2 = %01000000 ENEMY_ANIMTYPE_YSINPLUS = %00100000 ENEMY_ANIMTYPE_LOOPMASK = %00001111 ENEMY_ANIMTYPE_LOOP_FREEZE = $00 ENEMY_ANIMTYPE_LOOP_FRAME4 = $01 ENEMY_ANIMTYPE_LOOP_FRAME2 = $02 ENEMY_ANIMTYPE_LOOP_THREEFRAME4 = $03 ENEMY_ANIMTYPE_LOOP_FOURFRAME8 = $04 ENEMY_ANIMTYPE_LOOP_XFLIP = $05 ENEMY_ANIMTYPE_LOOP_JUMP = $06 ENEMY_GRAVITY = $0050 ENEMY_JUMP_VELOCITY = $0320 ENEMY_COLLISIONJUMP_VELOCITY = $0400 ;---------------------------------------------------------------------------------- ; is used for the axe to determine which direction it should be thrown enemyTemp dc.b $00 enemyTemp2 dc.b $00 InitFrog SUBROUTINE lda #SPRITEFRAMES_ENEMY1 sta GameObjectSpriteValue,x sta GameObjectSpriteImage,x lda #ENEMY_ANIMTYPE_LOOP_THREEFRAME4|ENEMY_ANIMTYPE_SLOWER1 sta GameObjectAnimType,x lda #ENEMY_CONFIGURATIONFLAG_XMOVEMENT|ENEMY_CONFIGURATIONFLAG_GRAVITY|ENEMY_CONFIGURATIONFLAG_FLOOR_HANDLING|ENEMY_CONFIGURATIONFLAG_RANDOM_JUMPING sta GameObjectConfiguration,x jmp enemyFlippedX InitBird SUBROUTINE lda #SPRITEFRAMES_ENEMY2 sta GameObjectSpriteValue,x sta GameObjectSpriteImage,x lda #ENEMY_ANIMTYPE_LOOP_THREEFRAME4|ENEMY_ANIMTYPE_SLOWER1|ENEMY_ANIMTYPE_YSINPLUS sta GameObjectAnimType,x lda #ENEMY_CONFIGURATIONFLAG_XMOVEMENT_HALVE_SPEED sta GameObjectConfiguration,x jmp enemyFlippedX InitBomby SUBROUTINE lda #SPRITEFRAMES_ENEMY3 sta GameObjectSpriteValue,x sta GameObjectSpriteImage,x lda #ENEMY_ANIMTYPE_LOOP_FRAME2|ENEMY_ANIMTYPE_SLOWER1 sta GameObjectAnimType,x lda #ENEMY_CONFIGURATIONFLAG_XMOVEMENT_HALVE_SPEED|ENEMY_CONFIGURATIONFLAG_FLOOR_HANDLING|ENEMY_CONFIGURATIONFLAG_PERIODICAL_SHOT sta GameObjectConfiguration,x jmp enemyFlippedX ; uses handleportalenemy InitDog SUBROUTINE lda #SPRITEFRAMES_ENEMY6 sta GameObjectSpriteValue,x sta GameObjectSpriteImage,x lda #ENEMY_ANIMTYPE_LOOP_FRAME2|ENEMY_ANIMTYPE_SLOWER1 sta GameObjectAnimType,x lda #$00 sta GameObjectConfiguration,x sta GameObjectVisible,x lda #GAMEOBJECT_COLLISIONTYPE_NO_COLLISION sta GameObjectCollisionType,x lda portalEnabled beq .notenabled lda #$01 sta portalEnabled lda #PORTALWAIT sta GameObjectVar8,x lda #$00 sta GameObjectVar9,x lda #255-8 sta GameObjectActiveCounter,x .notenabled jmp enemyFlippedX InitFat SUBROUTINE lda #SPRITEFRAMES_ENEMY4 sta GameObjectSpriteValue,x sta GameObjectSpriteImage,x lda #ENEMY_ANIMTYPE_LOOP_FRAME2|ENEMY_ANIMTYPE_SLOWER1 sta GameObjectAnimType,x lda #ENEMY_CONFIGURATIONFLAG_XMOVEMENT_HALVE_SPEED|ENEMY_CONFIGURATIONFLAG_FLOOR_HANDLING|ENEMY_CONFIGURATIONFLAG_PERIODICAL_SHOT sta GameObjectConfiguration,x jmp enemyFlippedX InitThrower SUBROUTINE lda #SPRITEFRAMES_ENEMY5 sta GameObjectSpriteValue,x sta GameObjectSpriteImage,x lda #ENEMY_ANIMTYPE_LOOP_FRAME2|ENEMY_ANIMTYPE_SLOWER1 sta GameObjectAnimType,x lda #ENEMY_CONFIGURATIONFLAG_XMOVEMENT_HALVE_SPEED|ENEMY_CONFIGURATIONFLAG_FLOOR_HANDLING ;|ENEMY_CONFIGURATIONFLAG_PERIODICAL_SHOT sta GameObjectConfiguration,x jmp enemyFlippedX InitEnemyShot1 SUBROUTINE axeSoundTrigger lda #SOUND_LAZER jsr triggerSoundScreen lda #SPRITEFRAMES_ENEMYSHOT1 sta GameObjectSpriteValue,x sta GameObjectSpriteImage,x lda #ENEMY_ANIMTYPE_LOOP_XFLIP|ENEMY_ANIMTYPE_SLOWER1 sta GameObjectAnimType,x ; floor handling must be off it is only for floor walking objects lda #ENEMY_CONFIGURATIONFLAG_XMOVEMENT|ENEMY_CONFIGURATIONFLAG_EXPLODE_ON_COLLISION sta GameObjectConfiguration,x lda #$00 sta GameObjectVar1,x sta GameObjectVar2,x sta GameObjectHitPoints,x lda #$ff sta GameObjectVar3,x lda enemyTemp sta GameObjectFlags1,x lda #$02 sta GameObjectFlags2,x rts ;jmp enemyFlippedX InitEnemyShot2 SUBROUTINE ;lda #SOUND_SHOT ;sta axeSoundTrigger + 1 jsr InitEnemyShot1 ;lda #SOUND_ENEMY_LAZER ;sta axeSoundTrigger + 1 lda #SPRITEFRAMES_ENEMYSHOT2 sta GameObjectSpriteValue,x sta GameObjectSpriteImage,x lda #ENEMY_CONFIGURATIONFLAG_GRAVITY|ENEMY_CONFIGURATIONFLAG_XMOVEMENT|ENEMY_CONFIGURATIONFLAG_EXPLODE_ON_COLLISION|ENEMY_CONFIGURATIONFLAG_COLLISION_JUMPING sta GameObjectConfiguration,x lda #<[-$0200] sta GameObjectVar1,x lda #>[-$0200] sta GameObjectVar2,x rts enemyFlippedX SUBROUTINE lda GameObjectXPosLo,x sec sbc GameObjectXPosLo + PLAYERGAMEOBJECT lda GameObjectXPosHi,x sbc GameObjectXPosHi + PLAYERGAMEOBJECT bmi .neg lda #$00 sta GameObjectFlags1,x rts .neg lda #$01 sta GameObjectFlags1,x rts ;--------------------------------------------------------- ;--- the configurable standard enemy --- ;--------------------------------------------------------- HandleStandardEnemy SUBROUTINE ; explode if behind stone lda GameObjectFlags1,x lsr lda GameObjectVar10,x rol sta GameObjectVar10,x cmp #%00110011 ; the flipping enemy is somehow a little wrong (2 times instead of one time) bne .nothanginginlevel ldy enemyNr jmp .explodeit .nothanginginlevel lda #$00 sta enemyTemp ; JUMPING ENEMY ? lda GameObjectConfiguration,x and #ENEMY_CONFIGURATIONFLAG_RANDOM_JUMPING beq .notjumping ; check if jump txa asl clc adc GameObjectActiveCounter,x and #$3f sta enemyTemp bne .nojump jsr collisionEnemyDown cmp #$00 beq .notjumping lda #SOUND_LITTLEJUMP ;lda #SOUND_JUMP jsr triggerSoundScreen lda #<[-ENEMY_JUMP_VELOCITY] sta GameObjectVar1,x lda #>[-ENEMY_JUMP_VELOCITY] sta GameObjectVar2,x lda #$ff sta GameObjectVar3,x .nojump ; only check top y if jumping is enabled jsr collisionEnemyUp cmp #$00 beq .notcollided2 lda #$00 sta GameObjectVar1,x sta GameObjectVar2,x sta GameObjectVar3,x .notcollided2 .herenocollision .notjumping lda GameObjectEnemyType,x cmp #ENEMY_TYPE_SPECIALENEMY bne .noshotit lda enemyTemp cmp #$04 beq .shotit cmp #$06 bne .noshotit .shotit lda GameObjectFlags1,x eor #$01 sta GameObjectFlags1,x txa tay jmp .shot .noshotit lda GameObjectConfiguration,x and #ENEMY_CONFIGURATIONFLAG_GRAVITY | ENEMY_CONFIGURATIONFLAG_RANDOM_JUMPING beq .noymovement lda GameObjectYPosLoLo,x clc adc GameObjectVar1,x sta GameObjectYPosLoLo,x lda GameObjectYPosLo,x adc GameObjectVar2,x sta GameObjectYPosLo,x lda GameObjectYPosHi,x adc GameObjectVar3,x sta GameObjectYPosHi,x .noymovement ; GRAVITY ? lda GameObjectConfiguration,x and #ENEMY_CONFIGURATIONFLAG_GRAVITY beq .nogravity ; handle y movement lda GameObjectVar1,x clc adc #<ENEMY_GRAVITY sta GameObjectVar1,x lda GameObjectVar2,x adc #>ENEMY_GRAVITY sta GameObjectVar2,x lda GameObjectVar3,x adc #$00 sta GameObjectVar3,x jsr collisionEnemyDown cmp #$00 beq .notcollided1 lda GameObjectConfiguration,x and #ENEMY_CONFIGURATIONFLAG_COLLISION_JUMPING beq .notCollisionJumping lda #SOUND_LITTLEJUMP ;lda #SOUND_JUMP jsr triggerSoundScreen lda #<[-ENEMY_COLLISIONJUMP_VELOCITY] sta GameObjectVar1,x lda #>[-ENEMY_COLLISIONJUMP_VELOCITY] sta GameObjectVar2,x lda #$ff sta GameObjectVar3,x rts .notCollisionJumping ; floor handling lda GameObjectConfiguration,x and #ENEMY_CONFIGURATIONFLAG_FLOOR_HANDLING beq .nofloorcollisionhandling lda #COLLISIONMODEFLAG_WITHFLOOR sta collisionMode .nofloorcollisionhandling lda #$00 sta GameObjectVar1,x sta GameObjectVar2,x sta GameObjectVar3,x .notcollided1 .nogravity ; handle FLIPPING (always enabled) lda GameObjectFlags1,x bne .notflipped lda #$01 jmp .storeflag .notflipped lda #$00 .storeflag sta GameObjectSpriteFlippedX,x ; set animation txa tay asl clc adc GameObjectActiveCounter,x lsr ; fixed 2nd frame here tax lda GameObjectAnimType,y and #ENEMY_ANIMTYPE_SLOWER1 beq .notslower1 txa lsr tax .notslower1 lda GameObjectAnimType,y and #ENEMY_ANIMTYPE_SLOWER2 beq .notslower2 txa lsr tax .notslower2 lda GameObjectAnimType,y and #ENEMY_ANIMTYPE_LOOPMASK cmp #ENEMY_ANIMTYPE_LOOP_FREEZE bne .notfreeze ldx #$00 jmp .animselected .notfreeze cmp #ENEMY_ANIMTYPE_LOOP_THREEFRAME4 bne .notthreeframe4 txa and #$03 tax lda threeFrameAnimation4,x tax jmp .animselected .notthreeframe4 cmp #ENEMY_ANIMTYPE_LOOP_FRAME4 bne .notframe4 txa and #$03 tax jmp .animselected .notframe4 cmp #ENEMY_ANIMTYPE_LOOP_FRAME2 bne .notframe2 txa and #$01 tax jmp .animselected .notframe2 cmp #ENEMY_ANIMTYPE_LOOP_FOURFRAME8 bne .notfourframe8 txa and #$07 tax lda fourFrameAnimation8,x tax jmp .animselected .notfourframe8 cmp #ENEMY_ANIMTYPE_LOOP_XFLIP bne .notxflipanimation txa and #$01 sta GameObjectSpriteFlippedX,y ldx #$00 jmp .animselected .notxflipanimation cmp #ENEMY_ANIMTYPE_LOOP_JUMP bne .notjumpinganimation ldx #$00 lda GameObjectVar3,y ora GameObjectVar2,y ora GameObjectVar1,y beq .justsitting lda GameObjectVar3,y bmi .fpinc1 inx .fpinc1 inx .justsitting jmp .animselected .notjumpinganimation .animselected txa clc adc GameObjectSpriteValue,y sta GameObjectSpriteImage,y lda GameObjectSpriteValue,y cmp #SPRITEFRAMES_ENEMYSHOT1 bne .notlazer jsr eAddLazerParticlesY .notlazer ldx enemyNr ldy enemyNr lda #$00 sta GameObjectSpritePaintWhite,x lda GameObjectHit,x beq .notdecwhite lda #$01 sta GameObjectSpritePaintWhite,x .notdecwhite lda GameObjectConfiguration,y and #ENEMY_CONFIGURATIONFLAG_RANDOM_JUMPING bne .floorcollisionisforjumpingalreadyhandled lda GameObjectConfiguration,y and #ENEMY_CONFIGURATIONFLAG_FLOOR_HANDLING beq .floorcollisionisforjumpingalreadyhandled lda #COLLISIONMODEFLAG_WITHFLOOR sta collisionMode .floorcollisionisforjumpingalreadyhandled lda #$02 sta enemyTemp2 .reloop lda GameObjectConfiguration,y and #ENEMY_CONFIGURATIONFLAG_XMOVEMENT|ENEMY_CONFIGURATIONFLAG_XMOVEMENT_HALVE_SPEED beq .noxmovement and #ENEMY_CONFIGURATIONFLAG_XMOVEMENT_HALVE_SPEED beq .nothalvexspeed lda GameObjectActiveCounter,y and #$01 beq .noxmovement .nothalvexspeed lda GameObjectFlags1,y and #$01 asl sec sbc #$01 ldx GameObjectFlags2,y cpx #$02 bne .notfaster asl .notfaster jsr enemyMoveX cmp #$00 beq .notFlipped ; should it explode lda GameObjectConfiguration,y and #ENEMY_CONFIGURATIONFLAG_EXPLODE_ON_COLLISION beq .notexplode .explodeit tya jsr explodeEnemy ldy enemyNr lda #GAMEOBJECT_COLLISIONTYPE_ENEMY_SHOT sta GameObjectCollisionType,y rts .notexplode lda GameObjectFlags1,y eor #$01 sta GameObjectFlags1,y jmp .noxmovement .notFlipped .noxmovement lda GameObjectEnemyType,y cmp #ENEMY_TYPE_ENEMYSHOT1 bne .notReloop lda gameLogikCounter and #$02 beq .notReloop dec enemyTemp2 bne .reloop .notReloop lda GameObjectAnimType,y and #ENEMY_ANIMTYPE_YSINPLUS beq .notsinplus lda GameObjectActiveCounter,y and #31 tax lda sinPlus,x jsr enemyMoveYNoCollision .notsinplus ; shooting (axe) lda GameObjectConfiguration,y and #ENEMY_CONFIGURATIONFLAG_PERIODICAL_SHOT beq .noshot lda GameObjectActiveCounter,y and #%1011111 bne .noshot .shot lda #ENEMY_TYPE_ENEMYSHOT1 sta enemyAddEnemyType lda GameObjectXPosLo,y sta enemyAddPosX + 0 lda GameObjectXPosHi,y sta enemyAddPosX + 1 lda #GAMEOBJECT_COLLISIONTYPE_ENEMY_SHOT sta enemyAddCollisionType lda #10 sta .adc + 1 lda GameObjectEnemyType,y cmp #ENEMY_TYPE_ENEMY4 beq .yeahgirl cmp #ENEMY_TYPE_ENEMY6 bne .notdog .yeahgirl lda #ENEMY_TYPE_ENEMYSHOT2 sta enemyAddEnemyType lda #0 sta .adc + 1 .notdog lda GameObjectYPosLo,y clc .adc adc #$44 sta enemyAddPosY + 0 lda GameObjectYPosHi,y adc #$00 sta enemyAddPosY + 1 lda GameObjectFlags1,y sta enemyTemp lda enemyNr pha lda enemyAddGameObjectIndexStart pha lda enemyAddGameObjectIndexEnd pha lda #ENEMYSHOTSFROM sta enemyAddGameObjectIndexStart lda #ENEMYSHOTSTO sta enemyAddGameObjectIndexEnd lda #NOLEVELENEMY sta enemyAddLevelEnemyIndex jsr addEnemyIntern pla sta enemyAddGameObjectIndexEnd pla sta enemyAddGameObjectIndexStart pla sta enemyNr .noshot rts ;--------------------------------------------------------- ;--- the background Animations --- ;--------------------------------------------------------- InitBackground SUBROUTINE lda enemyAddPropertyIntern sta GameObjectSpriteImage,x sta GameObjectSpriteValue,x lda enemyAddSpecialValue sta GameObjectVar1,x rts HandleBackground SUBROUTINE lda GameObjectXPosLo,x lsr lsr clc adc GameObjectActiveCounter,x lsr lsr lsr and #$03 tay lda threeFrameAnimation4,y clc adc GameObjectSpriteValue,x sta GameObjectSpriteImage,x rts InitSpecialEnemy SUBROUTINE rts HandleSpecialEnemy SUBROUTINE rts portalEnabled dc.b $00 PORTALWAIT = $10 HandlePortalEnemy SUBROUTINE lda portalEnabled bne .jo rts .jo lda GameObjectVar8,x cmp #PORTALWAIT beq .dontwait inc GameObjectVar8,x lda #$00 sta GameObjectActiveCounter,x rts .dontwait jsr HandleStandardEnemy ldx enemyNr lda #$01 sta GameObjectVisible,x lda GameObjectVar9,x bne .alreadybuildup lda GameObjectActiveCounter,x ; 32 * 8 = 256 lsr lsr lsr and #31 bne .do lda #$01 .do PORTALON sta .modi + 1 cmp #31 bne .notreadybuild lda #$01 sta GameObjectVar9,x lda portalEnabled cmp #$01 bne .rts inc portalEnabled lda #STONEENEMYTYPESTART + 4 sta enemyAddSpecialValue jsr AddMagicPre lda #<PORTALMAGICYPOS sta enemyAddPosY + 0 lda #>PORTALMAGICYPOS sta enemyAddPosY + 1 lda #<PORTALMAGICXPOS sta enemyAddPosX + 0 lda #>PORTALMAGICXPOS sta enemyAddPosX + 1 jsr addEnemyIntern ldx enemyNr .rts lda #$00 sta .modi + 1 ; 32 .notreadybuild lda GameObjectSpriteImage,x asl tay lda (ZP_SPRITES),y sta ZP_SPRITE_STRUCT_ADR + 0 iny lda (ZP_SPRITES),y sta ZP_SPRITE_STRUCT_ADR + 1 ldy #$00 lda (ZP_SPRITE_STRUCT_ADR),y and #%11100000 .modi ora #$44 sta (ZP_SPRITE_STRUCT_ADR),y .alreadybuildup rts
SECTION code_driver SECTION code_driver_terminal_output PUBLIC zx_01_output_char_32_tty_z88dk_23_atr zx_01_output_char_32_tty_z88dk_23_atr: ; atr dx,dy ; de = parameters * ex de,hl ld d,(hl) ; d = dy inc hl ld e,(hl) ; e = dx ex de,hl ld e,(ix+14) ; e = x ld d,(ix+15) ; d = y ld a,l add a,e ld e,a ; e = x + dx ld a,h add a,d ld d,a ; d = y + dy ld (ix+14),e ; store x coord ld (ix+15),d ; store y coord ret
; ******************************************************************************************** ; ******************************************************************************************** ; ; Name : const.asm ; Purpose : .. ; Created : 15th Nov 1991 ; Updated : 4th Jan 2021 ; Authors : Fred Bowen ; ; ******************************************************************************************** ; ******************************************************************************************** ; Constants used by LOG, EXP, TRIG, and others. fr4 !text 127,0,0,0,0 ; 1/4 neghlf !text 128,128,0,0,0 ; -0.5 fhalf !text 128,0,0,0,0 ; 0.5 tenc !text 132,32,0,0,0 ; 10.0 pival !text 130,73,15,218,161 ; pi pi2 !text 129,73,15,218,162 ; pi/2 twopi !text 131,73,15,218,162 ; pi*2 n0999 !text $9b,$3e,$bc,$1f,$fd n9999 !text $9e,$6e,$6b,$27,$fd nmil !text $9e,$6e,$6b,$28,$00 foutbl ; powers of 10 !text 250,10,31,0 ; -100,000,000 !text 0,152,150,128 ; 10,000,000 !text 255,240,189,192 ; -1,000,000 !text 0,1,134,160 ; 100,000 !text 255,255,216,240 ; -10,000 !text 0,0,3,232 ; 1,000 !text 255,255,255,156 ; -100 !text 0,0,0,10 ; 10 !text 255,255,255,255 ; -1 fdcend ; .byte @377,@337,@012,@200 ;-2,160,000 for time converter removed [901014] ; .byte @000,@003,@113,@300 ; 216,000 ; .byte @377,@377,@163,@140 ; -36,000 ; .byte @000,@000,@016,@020 ; 3,600 ; .byte @377,@377,@375,@250 ; -600 ; .byte @000,@000,@000,@074 ; 60 ;timend logcn2 !text 3 ; degree-1 !text 127,94,86,203,121 ; 0.43425594188 !text 128,19,155,11,100 ; 0.57658454134 !text 128,118,56,147,22 ; 0.96180075921 !text 130,56,170,59,32 ; 2.8853900728 expcon !text 7 ; degree-1 !text 113,52,88,62,86 ; 0.000021498763697 !text 116,22,126,179,27 ; 0.00014352314036 !text 119,47,238,227,133 ; 0.0013422634824 !text 122,29,132,28,42 ; 0.0096140170199 !text 124,99,89,88,10 ; 0.055505126860 !text 126,117,253,231,198 ; 0.24022638462 !text 128,49,114,24,16 ; 0.69314718600 fone !text 129,0,0,0,0 ; 1.0 logeb2 !text 129,56,170,59,41 ; log(e) base 2 sqr05 !text 128,53,4,243,52 ; 0.707106781 sqr(0.5) sqr20 !text 129,53,4,243,52 ; 1.41421356 sqr(2.0) log2 !text 128,49,114,23,248 ; 0.693147181 ln(2) sincon !text 5 ; degree-1 trig !text 132,230,26,45,27 !text 134,40,7,251,248 !text 135,153,104,137,1 !text 135,35,53,223,225 !text 134,165,93,231,40 !text 131,73,15,218,162 atncon !text 11 ; degree-1 !text 118,179,131,189,211 !text 121,30,244,166,245 !text 123,131,252,176,16 !text 124,12,31,103,202 !text 124,222,83,203,193 !text 125,20,100,112,76 !text 125,183,234,81,122 !text 125,99,48,136,126 !text 126,146,68,153,58 !text 126,76,204,145,199 !text 127,170,170,170,19 !text 129,0,0,0,0 ; ******************************************************************************************** ; ; Date Changes ; ==== ======= ; ; ********************************************************************************************
////////////////////////////////////////////////////////////////////////////// // nv_color_macs.asm // Copyright(c) 2021 Neal Smith. // License: MIT. See LICENSE file in root directory. ////////////////////////////////////////////////////////////////////////////// // This assembler file defines colors for the C64. these constants are // used throughout nv_c64_utils #importonce #if !NV_C64_UTIL_DATA .error "Error - nv_color_macs.asm: NV_C64_UTIL_DATA not defined. Import nv_c64_util_data.asm" #endif // the #if above doesn't seem to always work so.. // if data hasn't been imported yet, import it into default location #importif !NV_C64_UTIL_DATA "nv_c64_util_default_data.asm" // c64 colors .const NV_COLOR_BLACK = $00 .const NV_COLOR_WHITE = $01 .const NV_COLOR_RED = $02 .const NV_COLOR_CYAN = $03 .const NV_COLOR_PURPLE = $04 .const NV_COLOR_GREEN = $05 .const NV_COLOR_BLUE = $06 .const NV_COLOR_YELLOW = $07 .const NV_COLOR_ORANGE = $08 .const NV_COLOR_BROWN = $09 .const NV_COLOR_LITE_RED = $0a .const NV_COLOR_DARK_GREY = $0b .const NV_COLOR_GREY = $0c .const NV_COLOR_LITE_GREEN = $0d .const NV_COLOR_LITE_BLUE = $0e .const NV_COLOR_LITE_GREY = $0f .const NV_COLOR_FIRST = NV_COLOR_BLACK .const NV_COLOR_LAST = NV_COLOR_LITE_GREY
; A175006: Row sums of triangle A175009. ; 1,3,9,21,44,81,139,222,339,495,701,963,1294,1701,2199,2796,3509,4347,5329,6465,7776,9273,10979,12906,15079,17511,20229,23247,26594,30285,34351,38808,43689,49011,54809,61101,67924,75297,83259,91830,101051,110943,121549,132891,145014,157941,171719,186372,201949,218475,236001,254553,274184,294921,316819,339906,364239,389847,416789,445095,474826,506013,538719,572976,608849,646371,685609,726597,769404,814065,860651,909198,959779,1012431,1067229,1124211,1183454,1244997,1308919,1375260,1444101,1515483,1589489,1666161,1745584,1827801,1912899,2000922,2091959,2186055,2283301,2383743,2487474,2594541,2705039,2819016,2936569,3057747,3182649,3311325,3443876,3580353,3720859,3865446,4014219,4167231,4324589,4486347,4652614,4823445,4998951,5179188,5364269,5554251,5749249,5949321,6154584,6365097,6580979,6802290,7029151,7261623,7499829,7743831,7993754,8249661,8511679,8779872,9054369,9335235,9622601,9916533,10217164,10524561,10838859,11160126,11488499,11824047,12166909,12517155,12874926,13240293,13613399,13994316,14383189,14780091,15185169,15598497,16020224,16450425,16889251,17336778,17793159,18258471,18732869,19216431,19709314,20211597,20723439,21244920,21776201,22317363,22868569,23429901,24001524,24583521,25176059,25779222,26393179,27018015,27653901,28300923,28959254,29628981,30310279,31003236,31708029,32424747,33153569,33894585,34647976,35413833,36192339,36983586,37787759,38604951,39435349,40279047,41136234,42007005,42891551,43789968,44702449,45629091,46570089,47525541,48495644,49480497,50480299,51495150,52525251,53570703,54631709,55708371,56800894,57909381,59034039,60174972,61332389,62506395,63697201,64904913,66129744,67371801,68631299,69908346,71203159,72515847,73846629,75195615,76563026,77948973,79353679,80777256,82219929,83681811,85163129,86663997,88184644,89725185,91285851,92866758,94468139,96090111,97732909,99396651,101081574,102787797,104515559,106264980,108036301,109829643,111645249,113483241,115343864,117227241,119133619,121063122,123015999,124992375 mov $30,$0 mov $32,$0 add $32,1 lpb $32 clr $0,30 mov $0,$30 sub $32,1 sub $0,$32 mov $27,$0 mov $29,$0 add $29,1 lpb $29 mov $0,$27 sub $29,1 sub $0,$29 cal $0,144065 ; Values of n such that the expression sqrt(4!*(n+1) + 1) yields an integer. mov $26,$0 cmp $26,0 add $0,$26 add $28,$0 lpe add $31,$28 lpe mov $1,$31
#include "athena/WiiSaveReader.hpp" #include "athena/WiiSave.hpp" #include "athena/WiiFile.hpp" #include "athena/WiiImage.hpp" #include "athena/WiiBanner.hpp" #include "athena/Utility.hpp" #include "athena/FileWriter.hpp" #include "md5.h" #include "aes.hpp" #include "ec.hpp" #include "sha1.h" #include <iostream> #include <iomanip> #include <cstring> namespace athena { namespace io { WiiSaveReader::WiiSaveReader(const atUint8* data, atUint64 length) : MemoryCopyReader(data, length) { setEndian(Endian::Big); } WiiSaveReader::WiiSaveReader(const std::string& filename) : MemoryCopyReader(filename) { setEndian(Endian::Big); } std::unique_ptr<WiiSave> WiiSaveReader::readSave() { WiiSave* ret = new WiiSave; if (length() < 0xF0C0) { atError("Not a valid WiiSave"); return nullptr; } WiiBanner* banner = this->readBanner(); if (!banner) { atError("Invalid banner"); return nullptr; } ret->setBanner(banner); atUint32 bkVer = readUint32(); if (bkVer != 0x00000070) { atError("Invalid BacKup header size"); return nullptr; } atUint32 bkMagic = readUint32(); if (bkMagic != 0x426B0001) { atError("Invalid BacKup header magic"); return nullptr; } /*atUint32 ngId =*/readUint32(); atUint32 numFiles = readUint32(); /*int fileSize =*/readUint32(); seek(8); // skip unknown data; atUint32 totalSize = readUint32(); seek(64); // Unknown (Most likely padding) seek(8); seek(6); seek(2); seek(0x10); std::vector<WiiFile*> files; for (atUint32 i = 0; i < numFiles; ++i) { WiiFile* file = readFile(); if (file) files.push_back(file); } ret->setRoot(buildTree(files)); readCerts(totalSize); return std::unique_ptr<WiiSave>(ret); } WiiBanner* WiiSaveReader::readBanner() { atUint8* dec = new atUint8[0xF0C0]; memset(dec, 0, 0xF0C0); std::unique_ptr<atUint8[]> buf = readUBytes(0xF0C0); atUint8* oldData = data(); atUint64 oldPos = position(); atUint64 oldLen = length(); atUint64 gameId; atUint32 bannerSize; atUint8 permissions; atUint8 md5[16]; atUint8 md5Calc[16]; atUint8 tmpIV[16]; memcpy(tmpIV, SD_IV, 16); std::cout << "Decrypting: banner.bin..."; std::unique_ptr<IAES> aes = NewAES(); aes->setKey(SD_KEY); aes->decrypt(tmpIV, buf.get(), dec, 0xF0C0); std::cout << "done" << std::endl; memset(md5, 0, 16); memset(md5Calc, 0, 16); // Read in the MD5 sum memcpy(md5, (dec + 0x0E), 0x10); // Write the blanker to the buffer memcpy((dec + 0x0E), MD5_BLANKER, 0x10); MD5Hash::MD5(md5Calc, dec, 0xF0C0); // Compare the Calculated MD5 to the one from the file. // This needs to be done incase the file is corrupted. if (memcmp(md5, md5Calc, 0x10)) { std::cerr << "MD5 Mismatch" << std::endl; // Make sure to reset m_reader values back to the old ones. std::cerr << "MD5 provided: "; for (int i = 0; i < 16; ++i) std::cerr << std::setw(2) << std::setfill('0') << std::hex << (int)(md5[i]); std::cerr << std::endl; std::cerr << "MD5 Calculated: "; for (int i = 0; i < 16; ++i) std::cerr << std::hex << (int)(md5Calc[i]); std::cerr << std::endl; setData(oldData, oldLen); seek(oldPos, SeekOrigin::Begin); atError("MD5 Mismatch"); return nullptr; } // Set the binary reader buffer; setData(dec, 0xF0C0); // Start reading the header gameId = readUint64(); bannerSize = readUint32(); permissions = readByte(); /* unk =*/readByte(); seek(0x10); // skip padding seek(2); int magic; int flags; short animSpeed; std::u16string gameTitle; std::u16string subTitle; magic = readUint32(); // Ensure that the header magic is valid. if (magic != 0x5749424E) { // Make sure to reset m_reader values back to the old ones. setData(oldData, oldLen); seek(oldPos, SeekOrigin::Begin); atError("Invalid Header Magic"); return nullptr; } flags = readUint32(); animSpeed = readUint16(); seek(22); gameTitle = readU16StringBig(); if (position() != 0x0080) seek(0x0080, SeekOrigin::Begin); subTitle = readU16StringBig(); if (position() != 0x00C0) seek(0x00C0, SeekOrigin::Begin); WiiBanner* banner = new WiiBanner; banner->setGameID(gameId); banner->setTitle(gameTitle); banner->setSubtitle(subTitle); banner->setBannerSize(bannerSize); WiiImage* bannerImage = readImage(192, 64); banner->setBannerImage(bannerImage); banner->setAnimationSpeed(animSpeed); banner->setPermissions(permissions); banner->setFlags(flags); if (banner->bannerSize() == 0x72a0) { WiiImage* icon = readImage(48, 48); if (icon) banner->addIcon(icon); else std::cerr << "Warning: Icon empty, skipping" << std::endl; } else { for (int i = 0; i < 8; i++) { WiiImage* icon = readImage(48, 48); if (icon) banner->addIcon(icon); else std::cerr << "Warning: Icon empty, skipping" << std::endl; } } setData(oldData, oldLen); seek(oldPos, SeekOrigin::Begin); return banner; } WiiImage* WiiSaveReader::readImage(atUint32 width, atUint32 height) { std::unique_ptr<atUint8[]> image = readUBytes(width * height * 2); if (!utility::isEmpty((atInt8*)image.get(), width * height * 2)) return new WiiImage(width, height, std::move(image)); return NULL; } WiiFile* WiiSaveReader::readFile() { atUint32 fileLen; atUint8 permissions; atUint8 attributes; atUint8 type; std::string name; WiiFile* ret; atUint32 magic = readUint32(); if (magic != 0x03adf17e) { std::cerr << "Not a valid File entry header: 0x" << std::hex << magic << std::endl; return NULL; } fileLen = readUint32(); permissions = readByte(); attributes = readByte(); type = (WiiFile::Type)readByte(); name = std::string((const char*)readBytes(0x45).get()); ret = new WiiFile(std::string(name)); ret->setPermissions(permissions); ret->setAttributes(attributes); ret->setType((WiiFile::Type)type); std::unique_ptr<atUint8[]> iv = readUBytes(0x10); seek(0x20); if (type == WiiFile::File) { // Read file data int roundedLen = (fileLen + 63) & ~63; std::unique_ptr<atUint8[]> filedata = readUBytes(roundedLen); // Decrypt file std::cout << "Decrypting: " << ret->filename() << "..."; atUint8* decData = new atUint8[roundedLen]; std::unique_ptr<IAES> aes = NewAES(); aes->setKey(SD_KEY); aes->decrypt(iv.get(), filedata.get(), decData, roundedLen); ret->setData(decData); ret->setLength(fileLen); std::cout << "done" << std::endl; } return ret; } void WiiSaveReader::readCerts(atUint32 totalSize) { std::cout << "Reading certs..." << std::endl; atUint32 dataSize = totalSize - 0x340; std::unique_ptr<atUint8[]> sig = readUBytes(0x40); std::unique_ptr<atUint8[]> ngCert = readUBytes(0x180); std::unique_ptr<atUint8[]> apCert = readUBytes(0x180); seek(0xF0C0, SeekOrigin::Begin); std::unique_ptr<atUint8[]> data = readUBytes(dataSize); atUint8* hash; std::cout << "validating..." << std::endl; hash = getSha1(data.get(), dataSize); atUint8* hash2 = getSha1(hash, 20); bool ngValid = false; bool apValid = false; ecc::checkEC(ngCert.get(), apCert.get(), sig.get(), hash2, apValid, ngValid); if (apValid) std::cout << "AP Certificate ok" << std::endl; if (ngValid) std::cout << "NG Certificate ok" << std::endl; } WiiFile* WiiSaveReader::buildTree(std::vector<WiiFile*> files) { // This is simply a virtual root that will contain all the other nodes WiiFile* root = new WiiFile(""); root->setType(WiiFile::Directory); for (WiiFile* f : files) root->addChild(f); return root; } } // namespace io } // namespace athena
; A094639: Partial sums of squares of Catalan numbers (A000108). ; 1,2,6,31,227,1991,19415,203456,2248356,25887400,307993016,3763786812,47032778956,598933188956,7751562502556,101741582076581,1351906409905481,18159677984049581,246298405721739581 mov $2,$0 add $2,1 mov $4,$0 lpb $2 mov $0,$4 sub $2,1 sub $0,$2 seq $0,108 ; Catalan numbers: C(n) = binomial(2n,n)/(n+1) = (2n)!/(n!(n+1)!). mov $5,$0 pow $5,2 add $3,$5 lpe mov $0,$3
/************************************************************************* Crytek Source File. Copyright (C), Crytek Studios, 2001-2005. ------------------------------------------------------------------------- $Id$ $DateTime$ Description: Implements movement type for tracked vehicles ------------------------------------------------------------------------- History: - 13:06:2005: Created by MichaelR *************************************************************************/ #include "StdAfx.h" #include "Game.h" #include "GameCVars.h" #include <GameUtils.h> #include "IVehicleSystem.h" #include "VehicleMovementTank.h" #define THREAD_SAFE 1 //------------------------------------------------------------------------ CVehicleMovementTank::CVehicleMovementTank() { m_currPedal = 0; m_currSteer = 0; m_boostEndurance = 5.f; m_boostRegen = m_boostEndurance; m_boostStrength = 4.f; } //------------------------------------------------------------------------ CVehicleMovementTank::~CVehicleMovementTank() { } //------------------------------------------------------------------------ bool CVehicleMovementTank::Init(IVehicle* pVehicle, const CVehicleParams& table) { if (!inherited::Init(pVehicle, table)) return false; return true; } //------------------------------------------------------------------------ void CVehicleMovementTank::PostInit() { inherited::PostInit(); m_treadParts.clear(); int nParts = m_pVehicle->GetPartCount(); for (int i=0; i<nParts; ++i) { IVehiclePart* pPart = m_pVehicle->GetPart(i); if (pPart->GetType() == IVehiclePart::eVPT_Tread) { m_treadParts.push_back(pPart); } } } //------------------------------------------------------------------------ void CVehicleMovementTank::Reset() { inherited::Reset(); #ifdef DEBUG_TANK_AI m_debug.targetPos.zero(); m_debug.inputSpeed = 0.f; #endif } ////////////////////////////////////////////////////////////////////////// // NOTE: This function must be thread-safe. Before adding stuff contact MarcoC. void CVehicleMovementTank::ProcessMovement(const float deltaTime) { FUNCTION_PROFILER( gEnv->pSystem, PROFILE_GAME ); m_currPedal = fabsf(m_movementAction.power) > 0.05f ? m_movementAction.power : 0.f; if (m_movementAction.isAI) { m_damageRPMScale = 1.0f - 0.30f * m_damage; } else { float effectiveDamage = m_damage; m_damageRPMScale = GetWheelCondition(); m_damageRPMScale *= 1.0f - 0.4f*effectiveDamage; } inherited::ProcessMovement(deltaTime); } ////////////////////////////////////////////////////////////////////////// void CVehicleMovementTank::OnEvent(EVehicleMovementEvent event, const SVehicleMovementEventParams& params) { inherited::OnEvent(event,params); if (event == eVME_TireBlown || event == eVME_TireRestored) { // tracked vehicles don't have blowable tires, these events are sent on track destruction int numTreads = m_treadParts.size(); int treadsPrev = m_blownTires; m_blownTires = max(0, min(numTreads, event==eVME_TireBlown ? m_blownTires+1 : m_blownTires-1)); // reduce speed based on number of destroyed treads if (m_blownTires != treadsPrev) { SetEngineRPMMult(GetWheelCondition()); } } } //------------------------------------------------------------------------ void CVehicleMovementTank::OnAction(const TVehicleActionId actionId, int activationMode, float value) { CryAutoCriticalSection netlk(m_networkLock); CryAutoCriticalSection lk(m_lock); CVehicleMovementBase::OnAction(actionId, activationMode, value); } //------------------------------------------------------------------------ float CVehicleMovementTank::GetWheelCondition() const { if (0 == m_blownTires) return 1.0f; int numTreads = m_treadParts.size(); float treadCondition = (numTreads > 0) ? 1.0f - ((float)m_blownTires / numTreads) : 1.0f; return 0.6f + 0.4f*treadCondition; } #if ENABLE_VEHICLE_DEBUG //---------------------------------------------------------------------------------- void CVehicleMovementTank::DebugDrawMovement(const float deltaTime) { if (!IsProfilingMovement()) return; if (g_pGameCVars->v_profileMovement!=3) inherited::DebugDrawMovement(deltaTime); #ifdef DEBUG_TANK_AI if (m_movementAction.isAI) { IPhysicalEntity* pPhysics = GetPhysics(); IRenderer* pRenderer = gEnv->pRenderer; static float color[4] = {1,1,1,1}; float green[4] = {0,1,0,1}; float red[4] = {1,0,0,1}; static ColorB colRed(255,0,0,255); static ColorB colBlue(0,0,255,255); static ColorB colWhite(255,255,255,255); ColorB colGreen(0,255,0,255); ColorB col1(255,255,0,255); float y = 50.f, step1 = 15.f, step2 = 20.f, size=1.3f, sizeL=1.5f; IRenderAuxGeom* pAuxGeom = gEnv->pRenderer->GetIRenderAuxGeom(); SAuxGeomRenderFlags flags = pAuxGeom->GetRenderFlags(); SAuxGeomRenderFlags oldFlags = pAuxGeom->GetRenderFlags(); flags.SetDepthWriteFlag(e_DepthWriteOff); flags.SetDepthTestFlag(e_DepthTestOff); pAuxGeom->SetRenderFlags(flags); SVehiclePhysicsStatus* physStatus = &m_physStatus[k_mainThread]; Matrix33 bodyRot( physStatus->q ); Matrix34 bodyPose( bodyRot, physStatus->centerOfMass ); const Vec3 xAxis = bodyPose.GetColumn0(); const Vec3 yAxis = bodyPose.GetColumn1(); const Vec3 zAxis = bodyPose.GetColumn2(); const Vec3 chassisPos = bodyPose.GetColumn3(); if (!m_debug.targetPos.IsZero()) { Vec3 pos = physStatus->centerOfMass; Vec3 vMove = m_debug.targetPos - physStatus->centerOfMass; vMove = vMove - (vMove.dot(zAxis)) * zAxis; vMove.normalize(); vMove *= 3.f; // Draw move dir pAuxGeom->DrawSphere(pos, 0.1f, colGreen); pAuxGeom->DrawLine(pos, colGreen, pos + vMove, colGreen,4.0); pAuxGeom->DrawSphere(pos + vMove, 0.1f, colGreen); // Draw forward y-axis pAuxGeom->DrawLine(pos, colWhite, pos + 3.f*yAxis, colWhite, 4.0); // Draw Yaw input pAuxGeom->DrawLine(pos, colRed, pos + m_movementAction.rotateYaw*xAxis, colRed, 4.0); // Draw input speed pos = pos + 0.05f*xAxis; pAuxGeom->DrawLine(pos, colBlue, pos + (m_debug.inputSpeed*(3.f/5.f))*yAxis, colBlue, 4.0); } } #endif } #endif ////////////////////////////////////////////////////////////////////////// // NOTE: This function must be thread-safe. Before adding stuff contact MarcoC. void CVehicleMovementTank::ProcessAI(const float deltaTime) { FUNCTION_PROFILER( GetISystem(), PROFILE_GAME ); float dt = max( deltaTime, 0.005f); SVehiclePhysicsStatus* physStatus = &m_physStatus[k_physicsThread]; // Save the last steer state m_currSteer = m_movementAction.rotateYaw; m_movementAction.brake = false; m_movementAction.rotateYaw = 0.0f; m_movementAction.power = 0.0f; m_action.bHandBrake = 0; float inputSpeed = 0.0f; { if (m_aiRequest.HasDesiredSpeed()) inputSpeed = m_aiRequest.GetDesiredSpeed(); Limit(inputSpeed, -m_maxSpeed, m_maxSpeed); float distanceToPathEnd = m_aiRequest.GetDistanceToPathEnd(); if (distanceToPathEnd>=0.f) { inputSpeed *= 0.2f + 0.8f*min(1.f, distanceToPathEnd / 5.f); } } Vec3 vMove(ZERO); { if (m_aiRequest.HasMoveTarget()) vMove = m_aiRequest.GetMoveTarget() - physStatus->pos; } //start calculation if ( fabsf( inputSpeed ) < 0.0001f || m_tireBlownTimer > 1.5f ) { // only the case to use a hand break m_movementAction.brake = true; m_action.bHandBrake = 1; } else { float currentAngleSpeed = RAD2DEG(-physStatus->w.z); const static float maxSteer = RAD2DEG(gf_PI/4.f); // fix maxsteer, shouldn't change float currentSpeed = m_localSpeed.y; // calculate pedal static float accScale = 0.3f; m_movementAction.power = (inputSpeed - currentSpeed) * accScale; Limit( m_movementAction.power, -1.0f, 1.0f); // calculate angles Vec3 vMoveR = vMove * physStatus->q; Vec3 vFwd = FORWARD_DIRECTION; vMoveR.z =0.0f; vMoveR.NormalizeSafe(); if ( inputSpeed < 0.0 ) // when going back { vFwd = -vFwd; vMoveR = -vMoveR; currentAngleSpeed = -currentAngleSpeed; } float cosAngle = vFwd.Dot(vMoveR); float angle = RAD2DEG( acos_tpl(cosAngle)); float absAngle = fabsf(angle); if ( vMoveR.x < 0.f ) angle = -angle; if ( inputSpeed < 0.0 ) // when going back angle = -angle; static float steerAcc = 1.3f; m_movementAction.rotateYaw = fsgnf(angle) * sqrtf(clamp_tpl(fabsf(angle) * steerAcc / maxSteer, 0.f, 1.f)); // if there is enough angle speed, we don't need to steer more if ( fabsf(currentAngleSpeed) > absAngle && inputSpeed*angle*currentAngleSpeed > 0.0f ) { m_movementAction.rotateYaw = m_currSteer*0.95f; } // tank can rotate at a point m_movementAction.power *= 1.f - 0.05f * min(20.f, absAngle); m_prevAngle = angle; } #ifdef DEBUG_TANK_AI m_debug.targetPos = m_aiRequest.HasMoveTarget() ? m_aiRequest.GetMoveTarget() : Vec3(ZERO); m_debug.inputSpeed = inputSpeed; #endif } //------------------------------------------------------------------------ void CVehicleMovementTank::Update(const float deltaTime) { inherited::Update(deltaTime); #if ENABLE_VEHICLE_DEBUG DebugDrawMovement(deltaTime); #endif } //------------------------------------------------------------------------ void CVehicleMovementTank::GetMemoryUsage(ICrySizer * s) const { s->Add(*this); s->AddContainer(m_treadParts); inherited::GetMemoryUsage(s); }
; A082298: G.f.: (1-3*x-sqrt(9*x^2-10*x+1))/(2*x). ; Submitted by Christian Krause ; 1,4,20,116,740,5028,35700,261780,1967300,15072836,117297620,924612532,7367204260,59240277988,480118631220,3917880562644,32163325863300,265446382860420,2201136740855700,18329850024033012,153225552507991140,1285310632274024484,10815703760325080820,91275401523889689876,772328400542788444740,6551017308366846275268,55692091819122351708500,474443765631602956814900,4049658140104006304286500,34628757829372075940521060,296611926076082348831403700,2544641614366843892909441620 mov $1,1 mov $2,1 mov $3,$0 mov $4,2 lpb $3 mul $1,$3 mul $2,4 sub $3,1 mul $1,$3 add $5,$4 div $1,$5 add $2,$1 add $4,2 lpe mov $0,$2
; ************************************************************************************************ ; ************************************************************************************************ ; ; Name: test.asm ; Purpose: Tokenise testing code. ; Created: 8th March 2021 ; Reviewed: 16th March 2021 ; Author: Paul Robson (paul@robsons.org.uk) ; ; ************************************************************************************************ ; ************************************************************************************************ .section code ; ************************************************************************************************ ; ; Tokenise testing code. ; ; ************************************************************************************************ TokTest: ;; <test> ldx #$FF txs set16 codePtr,TokenText1 jsr Tokenise TokStop: ldx #0 ; compare vs precalculated result _TokCheck: lda TokenBytes1,x cmp tokenBuffer,x _TokFail: bne _TokFail ; error. inx cmp #$80 bne _TokCheck jmp $FFFF ; successfully tokenised then quit. .include "../../generated/toktest.inc" .send code
; A289617: a(n) = A005187(A001222(n)). ; 0,1,1,3,1,3,1,4,3,3,1,4,1,3,3,7,1,4,1,4,3,3,1,7,3,3,4,4,1,4,1,8,3,3,3,7,1,3,3,7,1,4,1,4,4,3,1,8,3,4,3,4,1,7,3,7,3,3,1,7,1,3,4,10,3,4,1,4,3,4,1,8,1,3,4,4,3,4,1,8,7,3,1,7,3,3,3,7,1,7,3,4,3,3,3,10,1,4,4,7 seq $0,1222 ; Number of prime divisors of n counted with multiplicity (also called bigomega(n) or Omega(n)). lpb $0 add $1,$0 div $0,2 lpe mov $0,$1
; A229803: Domination number for rook graph HR(n) on a triangular board of hexagonal cells. The rook can move along any row of adjacent cells, in any of the three directions. ; 1,1,2,2,3,3,3,4,4,5,5,6,6,7,7,8,8,9,9,9 mul $0,6 add $0,15 div $0,13 mov $1,$0
; ; Sharp OZ family functions ; ; ported from the OZ-7xx SDK by by Alexander R. Pruss ; by Stefano Bodrato - Oct. 2003 ; ; ; gfx functions ; ; Videmo memory page handling ; ; ; ------ ; $Id: ozactivatedisplaypage.asm,v 1.3 2016-06-28 14:48:17 dom Exp $ ; SECTION code_clib PUBLIC ozactivatedisplaypage PUBLIC _ozactivatedisplaypage EXTERN ozactivepage ozactivatedisplaypage: _ozactivatedisplaypage: in a,(22h) ld (ozactivepage),a ; in a,(23h) ; and 0fh ; ld (ozactivepage+1),a ret
; Unset a window definition section utility xdef ut_unset ;+++ ; Unset a window definition and release its space ; ; Entry Exit ; a4 window working definition ;--- ut_unset mt.alchp equ $18 mt.rechp equ $19 wm.unset equ $14 wm.setup equ $04 movem.l d0/a0,-(sp) keep channel ID jsr wm.unset(a2) unset current definition move.l a4,a0 archreg reg d1-d3/a1-a3 moveq #mt.rechp,d0 movem.l archreg,-(sp) moveq #-1,d2 trap #1 movem.l (sp)+,archreg movem.l (sp)+,d0/a0 rts end
/* * Copyright (c) 2013, Alexander Fronkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <cerrno> #include <cstdarg> #include <cstdio> #include <cstdlib> #include "marcrecord_tools.h" namespace marcrecord { /* * Print formatted output to std::string. */ int snprintf(std::string &s, size_t n, const char *format, ...) { va_list ap; char *buf; int resultCode; buf = (char *) malloc(n + 1); va_start(ap, format); resultCode = vsnprintf(buf, n + 1, format, ap); va_end(ap); if (resultCode >= 0) { s.append(buf); } free(buf); return resultCode; } /* * Serialize XML string. */ std::string serialize_xml(std::string &s) { std::string dest = ""; /* * Copy characters from source sting to destination string, * replace special characters. */ for (std::string::iterator it = s.begin(); it != s.end(); it++) { unsigned char c = *it; switch (c) { case '"': dest.append("&quot;"); break; case '&': if ((it + 1) == s.end() || *(it + 1) != '#') { dest.append("&amp;"); } else { dest += c; } break; case '\'': dest.append("&apos;"); break; case '<': dest.append("&lt;"); break; case '>': dest.append("&gt;"); break; default: dest += c; break; } } return dest; } /* * Verify that all string characters are decimal digits in ASCII encoding. */ int is_numeric(const char *s, size_t n) { char *p, *s_end; s_end = (char *) s + n; for (p = (char *) s; p < s_end && *p != '\0'; p++) { if (*p < 0x30 || *p > 0x39) { return 0; } } return 1; } /* * Convert encoding for std::string. */ bool iconv(iconv_t iconv_desc, const std::string &src, std::string &dest) { char buf[4096]; #ifndef ICONV_CONST_CHAR char *p = (char *) src.c_str(); #else const char *p = src.c_str(); #endif size_t src_len = src.size(); dest = ""; while (src_len > 0) { size_t dest_len = sizeof(buf); char *q = buf; if (::iconv(iconv_desc, &p, &src_len, &q, &dest_len) == (size_t) -1) { if (errno != E2BIG) { return false; } } dest.append(buf, sizeof(buf) - dest_len); } return true; } /* * Convert encoding for std::string. */ bool iconv(iconv_t iconv_desc, const char *src, size_t len, std::string &dest) { char buf[4096]; #ifndef ICONV_CONST_CHAR char *p = (char *) src; #else const char *p = src; #endif size_t src_len = len; dest = ""; while (src_len > 0) { size_t dest_len = sizeof(buf); char *q = buf; if (::iconv(iconv_desc, &p, &src_len, &q, &dest_len) == (size_t) -1) { if (errno != E2BIG) { return false; } } dest.append(buf, sizeof(buf) - dest_len); } return true; } } // namespace marcrecord
// Copyright 2012 Google Inc. All Rights Reserved. // // 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. #include "includes_normalize.h" #include "string_piece.h" #include "string_piece_util.h" #include "util.h" #include <algorithm> #include <iterator> #include <sstream> #include <windows.h> using namespace std; namespace { bool InternalGetFullPathName(const StringPiece& file_name, char* buffer, size_t buffer_length, string *err) { DWORD result_size = GetFullPathNameA(file_name.AsString().c_str(), buffer_length, buffer, NULL); if (result_size == 0) { *err = "GetFullPathNameA(" + file_name.AsString() + "): " + GetLastErrorString(); return false; } else if (result_size > buffer_length) { *err = "path too long"; return false; } return true; } bool IsPathSeparator(char c) { return c == '/' || c == '\\'; } // Return true if paths a and b are on the same windows drive. // Return false if this function cannot check // whether or not on the same windows drive. bool SameDriveFast(StringPiece a, StringPiece b) { if (a.size() < 3 || b.size() < 3) { return false; } if (!islatinalpha(a[0]) || !islatinalpha(b[0])) { return false; } if (ToLowerASCII(a[0]) != ToLowerASCII(b[0])) { return false; } if (a[1] != ':' || b[1] != ':') { return false; } return IsPathSeparator(a[2]) && IsPathSeparator(b[2]); } // Return true if paths a and b are on the same Windows drive. bool SameDrive(StringPiece a, StringPiece b, string* err) { if (SameDriveFast(a, b)) { return true; } char a_absolute[_MAX_PATH]; char b_absolute[_MAX_PATH]; if (!InternalGetFullPathName(a, a_absolute, sizeof(a_absolute), err)) { return false; } if (!InternalGetFullPathName(b, b_absolute, sizeof(b_absolute), err)) { return false; } char a_drive[_MAX_DIR]; char b_drive[_MAX_DIR]; _splitpath(a_absolute, a_drive, NULL, NULL, NULL); _splitpath(b_absolute, b_drive, NULL, NULL, NULL); return _stricmp(a_drive, b_drive) == 0; } // Check path |s| is FullPath style returned by GetFullPathName. // This ignores difference of path separator. // This is used not to call very slow GetFullPathName API. bool IsFullPathName(StringPiece s) { if (s.size() < 3 || !islatinalpha(s[0]) || s[1] != ':' || !IsPathSeparator(s[2])) { return false; } // Check "." or ".." is contained in path. for (size_t i = 2; i < s.size(); ++i) { if (!IsPathSeparator(s[i])) { continue; } // Check ".". if (i + 1 < s.size() && s[i+1] == '.' && (i + 2 >= s.size() || IsPathSeparator(s[i+2]))) { return false; } // Check "..". if (i + 2 < s.size() && s[i+1] == '.' && s[i+2] == '.' && (i + 3 >= s.size() || IsPathSeparator(s[i+3]))) { return false; } } return true; } } // anonymous namespace IncludesNormalize::IncludesNormalize(const string& relative_to) { string err; relative_to_ = AbsPath(relative_to, &err); if (!err.empty()) { Fatal("Initializing IncludesNormalize(): %s", err.c_str()); } split_relative_to_ = SplitStringPiece(relative_to_, '/'); } string IncludesNormalize::AbsPath(StringPiece s, string* err) { if (IsFullPathName(s)) { string result = s.AsString(); for (size_t i = 0; i < result.size(); ++i) { if (result[i] == '\\') { result[i] = '/'; } } return result; } char result[_MAX_PATH]; if (!InternalGetFullPathName(s, result, sizeof(result), err)) { return ""; } for (char* c = result; *c; ++c) if (*c == '\\') *c = '/'; return result; } string IncludesNormalize::Relativize( StringPiece path, const vector<StringPiece>& start_list, string* err) { string abs_path = AbsPath(path, err); if (!err->empty()) return ""; vector<StringPiece> path_list = SplitStringPiece(abs_path, '/'); int i; for (i = 0; i < static_cast<int>(min(start_list.size(), path_list.size())); ++i) { if (!EqualsCaseInsensitiveASCII(start_list[i], path_list[i])) { break; } } vector<StringPiece> rel_list; rel_list.reserve(start_list.size() - i + path_list.size() - i); for (int j = 0; j < static_cast<int>(start_list.size() - i); ++j) rel_list.push_back(".."); for (int j = i; j < static_cast<int>(path_list.size()); ++j) rel_list.push_back(path_list[j]); if (rel_list.size() == 0) return "."; return JoinStringPiece(rel_list, '/'); } bool IncludesNormalize::Normalize(const string& input, string* result, string* err) const { char copy[_MAX_PATH + 1]; size_t len = input.size(); if (len > _MAX_PATH) { *err = "path too long"; return false; } strncpy(copy, input.c_str(), input.size() + 1); uint64_t slash_bits; CanonicalizePath(copy, &len, &slash_bits); StringPiece partially_fixed(copy, len); string abs_input = AbsPath(partially_fixed, err); if (!err->empty()) return false; if (!SameDrive(abs_input, relative_to_, err)) { if (!err->empty()) return false; *result = partially_fixed.AsString(); return true; } *result = Relativize(abs_input, split_relative_to_, err); if (!err->empty()) return false; return true; }
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r9 push %rax push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0xf58a, %rdx sub %r9, %r9 movb (%rdx), %r13b nop nop nop nop sub %rsi, %rsi lea addresses_UC_ht+0x166ca, %rsi lea addresses_A_ht+0x18066, %rdi nop nop nop nop and %rax, %rax mov $59, %rcx rep movsq nop nop nop nop nop add $6281, %rcx lea addresses_UC_ht+0x17dca, %rsi lea addresses_WT_ht+0x5b90, %rdi clflush (%rsi) xor $46216, %rbp mov $64, %rcx rep movsl nop cmp $45225, %rbp lea addresses_UC_ht+0x1dc52, %r9 nop add %rcx, %rcx mov $0x6162636465666768, %rsi movq %rsi, %xmm6 and $0xffffffffffffffc0, %r9 movntdq %xmm6, (%r9) nop nop nop nop nop cmp $40609, %rbp lea addresses_WT_ht+0xa38a, %rsi lea addresses_UC_ht+0x17a8a, %rdi nop nop nop nop and $11967, %r13 mov $112, %rcx rep movsl nop nop xor $15711, %rdx lea addresses_WC_ht+0x1d68a, %rsi lea addresses_UC_ht+0x1a98a, %rdi nop nop cmp %rbp, %rbp mov $121, %rcx rep movsl nop nop nop nop nop inc %rdi lea addresses_WT_ht+0x1018a, %rsi nop sub $9621, %rbp mov $0x6162636465666768, %rdi movq %rdi, (%rsi) nop nop nop nop nop sub %rcx, %rcx lea addresses_UC_ht+0xab0a, %rsi lea addresses_normal_ht+0x718a, %rdi nop and %rbp, %rbp mov $61, %rcx rep movsl nop and %rdi, %rdi lea addresses_A_ht+0x1718a, %rbp nop add $1110, %rax mov (%rbp), %r13 nop nop nop nop and %rbp, %rbp lea addresses_D_ht+0x1358a, %rbp nop nop cmp $29591, %r13 mov (%rbp), %dx nop nop nop sub %r13, %r13 lea addresses_UC_ht+0x1098a, %r9 dec %rcx movb (%r9), %al nop nop sub $46503, %r9 lea addresses_D_ht+0x15f82, %rsi add %rcx, %rcx mov $0x6162636465666768, %rbp movq %rbp, %xmm3 movups %xmm3, (%rsi) and %rdx, %rdx lea addresses_normal_ht+0x66be, %rax nop nop sub $42773, %rbp movb $0x61, (%rax) add %rcx, %rcx lea addresses_A_ht+0x188a, %rax clflush (%rax) nop cmp $28906, %rsi mov $0x6162636465666768, %rcx movq %rcx, %xmm6 vmovups %ymm6, (%rax) nop nop nop sub %rcx, %rcx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %rax pop %r9 pop %r13 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r13 push %r15 push %r8 push %rax push %rcx // Load lea addresses_A+0x98a, %rcx nop nop nop nop dec %r13 mov (%rcx), %r8d nop dec %rcx // Load lea addresses_WC+0x840a, %r11 nop sub $56798, %r12 mov (%r11), %cx // Exception!!! nop mov (0), %r13 nop nop nop nop cmp %r12, %r12 // Load lea addresses_US+0xf98a, %r8 nop nop nop and $13333, %rcx movaps (%r8), %xmm7 vpextrq $0, %xmm7, %r12 nop nop nop sub %r13, %r13 // Load lea addresses_PSE+0xa74a, %r8 and $61401, %r12 movb (%r8), %r11b nop inc %rax // Load lea addresses_US+0xbd8a, %rcx nop nop nop nop and %r8, %r8 mov (%rcx), %r11w nop nop nop and $22688, %rax // Store lea addresses_D+0xb58a, %rax sub %r8, %r8 movl $0x51525354, (%rax) and $3837, %rcx // Faulty Load lea addresses_A+0x98a, %r15 nop nop nop nop add $30008, %r11 mov (%r15), %rcx lea oracles, %r12 and $0xff, %rcx shlq $12, %rcx mov (%r12,%rcx,1), %rcx pop %rcx pop %rax pop %r8 pop %r15 pop %r13 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_A', 'same': False, 'size': 16, 'congruent': 0, 'NT': True, 'AVXalign': True}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A', 'same': True, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WC', 'same': False, 'size': 2, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_US', 'same': False, 'size': 16, 'congruent': 11, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} {'src': {'type': 'addresses_PSE', 'same': False, 'size': 1, 'congruent': 5, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} {'src': {'type': 'addresses_US', 'same': False, 'size': 2, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_D', 'same': False, 'size': 4, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_A', 'same': True, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 1, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 16, 'congruent': 3, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 8, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_A_ht', 'same': False, 'size': 8, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D_ht', 'same': False, 'size': 2, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 1, 'congruent': 11, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_D_ht', 'same': True, 'size': 16, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_normal_ht', 'same': True, 'size': 1, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 32, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'35': 21829} 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 */
; Top-hole Golf ; Copyright 2020-2021 Matthew Clarke ; FIXME: possible optimizations. ; After calling spr_calc_dx/dy, won't always need to call a corresponding ; spr_move routine. Store dx/dy value in accumulator at end of initial ; routine to allow user to check it quickly for zero?! ; After a spr_move routine, update bb automatically based on delta or ; clamped value?! ; ***************** ; *** CONSTANTS *** ; ***************** spr_c_VISIBLE_ALL_L = 24 spr_c_VISIBLE_ALL_R = 64 ; With MSB set. spr_c_VISIBLE_ALL_T = 50 spr_c_VISIBLE_ALL_B = 229 spr_c_OFFSCREEN_L = 0 spr_c_OFFSCREEN_R = 88 spr_c_OFFSCREEN_T = 29 spr_c_OFFSCREEN_B = 250 spr_c_LEFT = 0 spr_c_RIGHT = 1 spr_c_UP = 2 spr_c_DOWN = 3 spr_c_CURRENT_CHAR_ZP_LO = 59 spr_c_CURRENT_CHAR_ZP_HI = 60 ; ***************** ; *** VARIABLES *** ; ***************** ; Make sure variables are aligned with page boundary because they'll be ; accessed with X register as index. Room for 32 arrays of 8 bytes each. ;!align 255, 0 spr_v_x_lo !fill 16,0 spr_v_x_hi !fill 16,0 spr_v_y !fill 16,0 spr_v_vx_lo !fill 16,0 spr_v_vx_hi !fill 16,0 spr_v_vy_lo !fill 16,0 spr_v_vy_hi !fill 16,0 spr_v_vx_count !fill 16,0 spr_v_vy_count !fill 16,0 spr_v_direction_x !fill 16,0 spr_v_direction_y !fill 16,0 spr_v_anim_start_ptr !fill 16,0 spr_v_anim_end_ptr !fill 16,0 spr_v_anim_seq_inc !fill 16,0 spr_v_anim_timer !fill 16,0 spr_v_framerate !fill 16,0 spr_v_current_ptr !fill 16,0 spr_v_dx !fill 16,0 spr_v_dy !fill 16,0 spr_v_color !fill 16,0 spr_v_yxpand !fill 16,0 spr_v_xxpand !fill 16,0 spr_v_bg_priority !fill 16,0 ; NOTE: all sprites are m/c by default. spr_v_hires !fill 16,0 ; NOTE: should be 16-bit really! spr_v_fg_priority !byte 0 ; Used with the spr_clamp_ routines. spr_v_edge !byte 0 ; Used with spr_animate_onetime routine. ; Is set if advanced to next frame in this call. spr_v_is_next_frame !byte 0 ; ************** ; *** MACROS *** ; ************** ; ******************* ; *** SUBROUTINES *** ; ******************* ; X = sprite number (0-7) ; NOTE: sprite will be clamped at left edge where x=0. !zone { spr_s_move_left lda spr_v_x_lo,x sec sbc spr_v_dx,x sta spr_v_x_lo,x lda spr_v_x_hi,x sbc #0 sta spr_v_x_hi,x ; If bit #8 (i.e. MSB) goes below 0, we've reached left edge of screen ; (hidden by border). If C flag set, however, everything's fine. bcs .end ; Clamp at position X=0. lda #0 sta spr_v_x_lo,x sta spr_v_x_hi,x .end rts ; end sub spr_s_move_left } ; !zone ; ************************************************** ; X = sprite number (0-7) !zone { spr_s_move_right lda spr_v_x_lo,x clc adc spr_v_dx,x sta spr_v_x_lo,x lda spr_v_x_hi,x adc #0 sta spr_v_x_hi,x ; NOTE: we assume client isn't going to allow x to wrap around at ; right-hand of screen. rts ; end sub spr_s_move_right } ; !zone ; ************************************************** ; X = sprite number (0-7). ; NOTE: clamps sprite at 0. !zone { spr_s_move_up lda spr_v_y,x sec sbc spr_v_dy,x bcc .clamp jmp .end .clamp lda #0 .end sta spr_v_y,x rts ; end sub spr_s_move_up } ; !zone ; ************************************************** !zone { ; X = sprite number (0-7). ; NOTE: clamps sprite at 255 ($ff). spr_s_move_down lda spr_v_y,x clc adc spr_v_dy,x bcs .clamp jmp .end .clamp lda #$ff .end sta spr_v_y,x rts ; end sub spr_s_move_down } ; !zone ; ************************************************** ; X = sprite number (0-7) spr_s_calc_dx lda spr_v_vx_count,x clc adc spr_v_vx_lo,x sta spr_v_vx_count,x lda spr_v_vx_hi,x bcc + clc adc #1 + sta spr_v_dx,x rts ; end sub spr_s_calc_dx ; ************************************************** ; X = sprite number (0-7) spr_s_calc_dy lda spr_v_vy_count,x clc adc spr_v_vy_lo,x sta spr_v_vy_count,x lda spr_v_vy_hi,x bcc + clc adc #1 + sta spr_v_dy,x rts ; end sub spr_s_calc_dy ; ************************************************** ;spr_s_clamp_top ; rts ; end sub spr_s_clamp_top ; ************************************************** ;spr_s_clamp_bottom ; rts ; end sub spr_s_clamp_bottom ; ************************************************** ; X = sprite number (0-7) ; Put edge in spr_edge variable. Lowest valid position, so sprite x should be ; >= to it. ; ASSUME MSB NEEDS TO BE CLEAR. !zone { spr_s_clamp_left lda spr_v_x_hi,x bne .end lda spr_v_x_lo,x cmp spr_v_edge bcs .end lda spr_v_edge sta spr_v_x_lo,x .end rts ; end sub spr_s_clamp_left } ; zone ; ************************************************** ; X = sprite number (0-7) ; Put edge in spr_edge variable. Highest valid position, so sprite x should be ; <= to it. ; ASSUME MSB NEEDS TO BE CLEAR. ; OUTPUT: C flag set if clamping was necessary; else clear. !zone { spr_s_clamp_right clc ; Increment spr_edge because that means we can test if cmp leaves C flag ; clear, in which case we're OK (A < memory). Otherwise clamp sprite x ; to original value of spr_edge. inc spr_v_edge lda spr_v_x_lo,x cmp spr_v_edge bcc .end dec spr_v_edge lda spr_v_edge sta spr_v_x_lo,x .end rts ; end sub spr_s_clamp_right } ; zone ; ************************************************** ; X = sprite number (0-7). ; NOTE: 'C' flag set if animation complete. !zone { spr_s_animate_onetime +clr spr_v_is_next_frame dec spr_v_anim_timer,x bne .end lda spr_v_framerate,x sta spr_v_anim_timer,x ; Check if the current frame is the last frame. In which case there's ; nowhere else to go. lda spr_v_current_ptr,x cmp spr_v_anim_end_ptr,x bne + sec rts + ; Set flag to show we're going to the next frame. inc spr_v_is_next_frame ; Increment or decrement as appropriate. lda spr_v_anim_seq_inc,x beq .decrease inc spr_v_current_ptr,x jmp .end .decrease dec spr_v_current_ptr,x .end clc rts ; end sub spr_s_animate_onetime } ; !zone ; ************************************************** ; X = sprite number (0-7). !zone { spr_animate_loop dec spr_v_anim_timer,x beq + rts + lda spr_v_framerate,x sta spr_v_anim_timer,x ; Check if the current frame is the last frame and if it is, go back to ; the beginning. lda spr_v_current_ptr,x cmp spr_v_anim_end_ptr,x bne + lda spr_v_anim_start_ptr,x sta spr_v_current_ptr,x rts + ; Not the last frame so just increment. inc spr_v_current_ptr,x rts ; end sub spr_animate_loop } ; !zone ; ************************************************** ; X = sprite number (0-7). ;!zone { ;spr_s_animate_pingpong ; dec spr_v_anim_timer,x ; bne .end ; ; lda spr_v_framerate,x ; sta spr_v_anim_timer,x ; ; lda spr_v_anim_seq_inc,x ; beq .decrease ; ; ; Increment sprite data pointer. ; inc spr_v_current_ptr,x ; lda spr_v_current_ptr,x ; cmp spr_v_anim_end_ptr,x ; bne .end ; lda #0 ; sta spr_v_anim_seq_inc,x ; jmp .end ; ;.decrease ; dec spr_v_current_ptr,x ; lda spr_v_current_ptr,x ; cmp spr_v_anim_start_ptr,x ; bne .end ; lda #1 ; sta spr_v_anim_seq_inc,x ; ;.end ; rts ;; end sub spr_s_animate_pingpong ;} ; !zone ; ************************************************** ; X = sprite # (0-7). ; Call this when place sprite at a new position manually to make sure MSIGX ; is set correctly. spr_s_sync_msb lda spr_v_x_hi,x beq + +spr_m_set_msb rts + +spr_m_clear_msb rts ; end sub spr_s_sync_msb ; ************************************************** !zone { spr_s_clear_msb_all lda #0 sta MSIGX ldx #7 - sta spr_v_x_hi,x dex bpl - rts ; end sub spr_s_clear_msb_all } ; !zone ; ************************************************** ; Y = sprite number (from) ; X = sprite number (to) !zone { spr_s_write_to_vic_ii ; YXPAND: lda spr_v_yxpand,y beq .clear_yxpand ; Set YXPAND. lda utils_l_BIT_LOOKUP,x ora YXPAND bne + .clear_yxpand lda utils_l_EOR_BIT_LOOKUP,x and YXPAND + sta YXPAND ; XXPAND: lda spr_v_xxpand,y beq .clear_xxpand ; Set XXPAND. lda utils_l_BIT_LOOKUP,x ora XXPAND bne + .clear_xxpand lda utils_l_EOR_BIT_LOOKUP,x and XXPAND + sta XXPAND ; SPBGPR: lda spr_v_bg_priority,y beq .clear_spbgpr ; Set SPBGPR. lda utils_l_BIT_LOOKUP,x ora SPBGPR bne + .clear_spbgpr lda utils_l_EOR_BIT_LOOKUP,x and SPBGPR + sta SPBGPR ; Multiply value in X by 2 so can index SP0X, etc. txa asl tax ; Position. lda spr_v_x_lo,y sta SP0X,x lda spr_v_y,y sta SP0X+1,x ; For MSB, put X back to where it was. txa lsr tax lda spr_v_x_hi,y beq + +spr_m_set_msb jmp ++ + +spr_m_clear_msb ++ ; Color. lda spr_v_color,y sta SP0COL,x ; Hires or multicolor sprite? lda spr_v_hires,y +branch_if_false .multicolor ; So it's hires. lda utils_l_EOR_BIT_LOOKUP,x and SPMC jmp + .multicolor lda utils_l_BIT_LOOKUP,x ora SPMC + sta SPMC ; Data pointer. lda spr_v_current_ptr,y sta gfxs_c_SPR_PTR_BASE,x rts ; end sub spr_s_write_to_vic_ii } ; !zone ; ************************************************** ; FIXME: also clears the f/g priority array! !zone { spr_s_clear_all_expands ldx #((3*16)-1) lda #0 - sta spr_v_yxpand,x dex bpl - rts ; end sub spr_s_clear_all_expands } ; !zone ; ************************************************** !zone { spr_s_hide_all ldx #15 lda #0 - sta SP0X,x dex bpl - sta YXPAND sta XXPAND rts ; end sub spr_s_hide_all } ; !zone ; ************************************************** ; ************************************************** ; ************************************************** ; ************************************************** ; ************************************************** ; ************************************************** ; **************************************************
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "core/frame/csp/CSPSource.h" #include "core/dom/Document.h" #include "core/frame/csp/ContentSecurityPolicy.h" #include "platform/network/ResourceRequest.h" #include "platform/weborigin/KURL.h" #include "platform/weborigin/SecurityOrigin.h" #include "testing/gtest/include/gtest/gtest.h" namespace blink { class CSPSourceTest : public ::testing::Test { public: CSPSourceTest() : csp(ContentSecurityPolicy::create()) {} protected: Persistent<ContentSecurityPolicy> csp; }; TEST_F(CSPSourceTest, BasicMatching) { KURL base; CSPSource source(csp.get(), "http", "example.com", 8000, "/foo/", CSPSource::NoWildcard, CSPSource::NoWildcard); EXPECT_TRUE(source.matches(KURL(base, "http://example.com:8000/foo/"))); EXPECT_TRUE(source.matches(KURL(base, "http://example.com:8000/foo/bar"))); EXPECT_TRUE(source.matches(KURL(base, "HTTP://EXAMPLE.com:8000/foo/BAR"))); EXPECT_FALSE(source.matches(KURL(base, "http://example.com:8000/bar/"))); EXPECT_FALSE(source.matches(KURL(base, "https://example.com:8000/bar/"))); EXPECT_FALSE(source.matches(KURL(base, "http://example.com:9000/bar/"))); EXPECT_FALSE(source.matches(KURL(base, "HTTP://example.com:8000/FOO/bar"))); EXPECT_FALSE(source.matches(KURL(base, "HTTP://example.com:8000/FOO/BAR"))); } TEST_F(CSPSourceTest, WildcardMatching) { KURL base; CSPSource source(csp.get(), "http", "example.com", 0, "/", CSPSource::HasWildcard, CSPSource::HasWildcard); EXPECT_TRUE(source.matches(KURL(base, "http://foo.example.com:8000/"))); EXPECT_TRUE(source.matches(KURL(base, "http://foo.example.com:8000/foo"))); EXPECT_TRUE(source.matches(KURL(base, "http://foo.example.com:9000/foo/"))); EXPECT_TRUE( source.matches(KURL(base, "HTTP://FOO.EXAMPLE.com:8000/foo/BAR"))); EXPECT_FALSE(source.matches(KURL(base, "http://example.com:8000/"))); EXPECT_FALSE(source.matches(KURL(base, "http://example.com:8000/foo"))); EXPECT_FALSE(source.matches(KURL(base, "http://example.com:9000/foo/"))); EXPECT_FALSE(source.matches(KURL(base, "http://example.foo.com:8000/"))); EXPECT_FALSE(source.matches(KURL(base, "https://example.foo.com:8000/"))); EXPECT_FALSE(source.matches(KURL(base, "https://example.com:8000/bar/"))); } TEST_F(CSPSourceTest, RedirectMatching) { KURL base; CSPSource source(csp.get(), "http", "example.com", 8000, "/bar/", CSPSource::NoWildcard, CSPSource::NoWildcard); EXPECT_TRUE( source.matches(KURL(base, "http://example.com:8000/"), ResourceRequest::RedirectStatus::FollowedRedirect)); EXPECT_TRUE( source.matches(KURL(base, "http://example.com:8000/foo"), ResourceRequest::RedirectStatus::FollowedRedirect)); EXPECT_TRUE( source.matches(KURL(base, "https://example.com:8000/foo"), ResourceRequest::RedirectStatus::FollowedRedirect)); EXPECT_FALSE( source.matches(KURL(base, "http://not-example.com:8000/foo"), ResourceRequest::RedirectStatus::FollowedRedirect)); EXPECT_FALSE(source.matches(KURL(base, "http://example.com:9000/foo/"), ResourceRequest::RedirectStatus::NoRedirect)); } TEST_F(CSPSourceTest, InsecureSchemeMatchesSecureScheme) { KURL base; CSPSource source(csp.get(), "http", "", 0, "/", CSPSource::NoWildcard, CSPSource::HasWildcard); EXPECT_TRUE(source.matches(KURL(base, "http://example.com:8000/"))); EXPECT_TRUE(source.matches(KURL(base, "https://example.com:8000/"))); EXPECT_TRUE(source.matches(KURL(base, "http://not-example.com:8000/"))); EXPECT_TRUE(source.matches(KURL(base, "https://not-example.com:8000/"))); EXPECT_FALSE(source.matches(KURL(base, "ftp://example.com:8000/"))); } TEST_F(CSPSourceTest, InsecureHostSchemeMatchesSecureScheme) { KURL base; CSPSource source(csp.get(), "http", "example.com", 0, "/", CSPSource::NoWildcard, CSPSource::HasWildcard); EXPECT_TRUE(source.matches(KURL(base, "http://example.com:8000/"))); EXPECT_FALSE(source.matches(KURL(base, "http://not-example.com:8000/"))); EXPECT_TRUE(source.matches(KURL(base, "https://example.com:8000/"))); EXPECT_FALSE(source.matches(KURL(base, "https://not-example.com:8000/"))); } TEST_F(CSPSourceTest, InsecureHostSchemePortMatchesSecurePort) { KURL base; CSPSource source(csp.get(), "http", "example.com", 80, "/", CSPSource::NoWildcard, CSPSource::NoWildcard); EXPECT_TRUE(source.matches(KURL(base, "http://example.com/"))); EXPECT_TRUE(source.matches(KURL(base, "http://example.com:80/"))); EXPECT_TRUE(source.matches(KURL(base, "http://example.com:443/"))); EXPECT_TRUE(source.matches(KURL(base, "https://example.com/"))); EXPECT_TRUE(source.matches(KURL(base, "https://example.com:80/"))); EXPECT_TRUE(source.matches(KURL(base, "https://example.com:443/"))); EXPECT_FALSE(source.matches(KURL(base, "http://example.com:8443/"))); EXPECT_FALSE(source.matches(KURL(base, "https://example.com:8443/"))); EXPECT_FALSE(source.matches(KURL(base, "http://not-example.com/"))); EXPECT_FALSE(source.matches(KURL(base, "http://not-example.com:80/"))); EXPECT_FALSE(source.matches(KURL(base, "http://not-example.com:443/"))); EXPECT_FALSE(source.matches(KURL(base, "https://not-example.com/"))); EXPECT_FALSE(source.matches(KURL(base, "https://not-example.com:80/"))); EXPECT_FALSE(source.matches(KURL(base, "https://not-example.com:443/"))); } TEST_F(CSPSourceTest, DoesNotSubsume) { struct Source { const char* scheme; const char* host; const char* path; const int port; }; struct TestCase { const Source a; const Source b; } cases[] = { {{"http", "example.com", "/", 0}, {"http", "another.com", "/", 0}}, {{"wss", "example.com", "/", 0}, {"http", "example.com", "/", 0}}, {{"wss", "example.com", "/", 0}, {"about", "example.com", "/", 0}}, {{"http", "example.com", "/", 0}, {"about", "example.com", "/", 0}}, {{"http", "example.com", "/1.html", 0}, {"http", "example.com", "/2.html", 0}}, {{"http", "example.com", "/", 443}, {"about", "example.com", "/", 800}}, }; for (const auto& test : cases) { CSPSource* returned = new CSPSource( csp.get(), test.a.scheme, test.a.host, test.a.port, test.a.path, CSPSource::NoWildcard, CSPSource::NoWildcard); CSPSource* required = new CSPSource( csp.get(), test.b.scheme, test.b.host, test.b.port, test.b.path, CSPSource::NoWildcard, CSPSource::NoWildcard); EXPECT_FALSE(required->subsumes(returned)); // Verify the same test with a and b swapped. EXPECT_FALSE(required->subsumes(returned)); } } TEST_F(CSPSourceTest, Subsumes) { struct Source { const char* scheme; const char* path; const int port; }; struct TestCase { const Source a; const Source b; bool expected; bool expectedWhenSwapped; } cases[] = { // Equal signals {{"http", "/", 0}, {"http", "/", 0}, true, true}, {{"https", "/", 0}, {"https", "/", 0}, true, true}, {{"https", "/page1.html", 0}, {"https", "/page1.html", 0}, true, true}, {{"http", "/", 70}, {"http", "/", 70}, true, true}, {{"https", "/", 70}, {"https", "/", 70}, true, true}, {{"https", "/page1.html", 0}, {"https", "/page1.html", 0}, true, true}, {{"http", "/page1.html", 70}, {"http", "/page1.html", 70}, true, true}, {{"https", "/page1.html", 70}, {"https", "/page1.html", 70}, true, true}, // One stronger signal in the first CSPSource {{"https", "/", 0}, {"http", "/", 0}, true, false}, {{"http", "/page1.html", 0}, {"http", "/", 0}, true, false}, {{"http", "/", 80}, {"http", "/", 0}, true, true}, {{"http", "/", 700}, {"http", "/", 0}, false, false}, // Two stronger signals in the first CSPSource {{"https", "/page1.html", 0}, {"http", "/", 0}, true, false}, {{"https", "/", 80}, {"http", "/", 0}, false, false}, {{"http", "/page1.html", 80}, {"http", "/", 0}, true, false}, // Three stronger signals in the first CSPSource {{"https", "/page1.html", 70}, {"http", "/", 0}, false, false}, // Mixed signals {{"https", "/", 0}, {"http", "/page1.html", 0}, false, false}, {{"https", "/", 0}, {"http", "/", 70}, false, false}, {{"http", "/page1.html", 0}, {"http", "/", 70}, false, false}, }; for (const auto& test : cases) { CSPSource* returned = new CSPSource( csp.get(), test.a.scheme, "example.com", test.a.port, test.a.path, CSPSource::NoWildcard, CSPSource::NoWildcard); CSPSource* required = new CSPSource( csp.get(), test.b.scheme, "example.com", test.b.port, test.b.path, CSPSource::NoWildcard, CSPSource::NoWildcard); EXPECT_EQ(required->subsumes(returned), test.expected); // Verify the same test with a and b swapped. EXPECT_EQ(returned->subsumes(required), test.expectedWhenSwapped); } // When returned CSP has a wildcard but the required csp doesn't, then it is // not subsumed. for (const auto& test : cases) { CSPSource* returned = new CSPSource( csp.get(), test.a.scheme, "example.com", test.a.port, test.a.path, CSPSource::HasWildcard, CSPSource::NoWildcard); CSPSource* required = new CSPSource( csp.get(), test.b.scheme, "example.com", test.b.port, test.b.path, CSPSource::NoWildcard, CSPSource::NoWildcard); EXPECT_FALSE(required->subsumes(returned)); // If required csp also allows a wildcard in host, then the answer should be // as expected. CSPSource* required2 = new CSPSource( csp.get(), test.b.scheme, "example.com", test.b.port, test.b.path, CSPSource::HasWildcard, CSPSource::NoWildcard); EXPECT_EQ(required2->subsumes(returned), test.expected); } } TEST_F(CSPSourceTest, WildcardsSubsumes) { struct Wildcards { CSPSource::WildcardDisposition hostDispotion; CSPSource::WildcardDisposition portDispotion; }; struct TestCase { const Wildcards a; const Wildcards b; bool expected; } cases[] = { // One out of four possible wildcards. {{CSPSource::HasWildcard, CSPSource::NoWildcard}, {CSPSource::NoWildcard, CSPSource::NoWildcard}, false}, {{CSPSource::NoWildcard, CSPSource::HasWildcard}, {CSPSource::NoWildcard, CSPSource::NoWildcard}, false}, {{CSPSource::NoWildcard, CSPSource::NoWildcard}, {CSPSource::NoWildcard, CSPSource::HasWildcard}, true}, {{CSPSource::NoWildcard, CSPSource::NoWildcard}, {CSPSource::HasWildcard, CSPSource::NoWildcard}, true}, // Two out of four possible wildcards. {{CSPSource::HasWildcard, CSPSource::HasWildcard}, {CSPSource::NoWildcard, CSPSource::NoWildcard}, false}, {{CSPSource::HasWildcard, CSPSource::NoWildcard}, {CSPSource::HasWildcard, CSPSource::NoWildcard}, true}, {{CSPSource::HasWildcard, CSPSource::NoWildcard}, {CSPSource::NoWildcard, CSPSource::HasWildcard}, false}, {{CSPSource::NoWildcard, CSPSource::HasWildcard}, {CSPSource::HasWildcard, CSPSource::NoWildcard}, false}, {{CSPSource::NoWildcard, CSPSource::HasWildcard}, {CSPSource::NoWildcard, CSPSource::HasWildcard}, true}, {{CSPSource::NoWildcard, CSPSource::NoWildcard}, {CSPSource::HasWildcard, CSPSource::HasWildcard}, true}, // Three out of four possible wildcards. {{CSPSource::HasWildcard, CSPSource::HasWildcard}, {CSPSource::HasWildcard, CSPSource::NoWildcard}, false}, {{CSPSource::HasWildcard, CSPSource::HasWildcard}, {CSPSource::NoWildcard, CSPSource::HasWildcard}, false}, {{CSPSource::HasWildcard, CSPSource::NoWildcard}, {CSPSource::HasWildcard, CSPSource::HasWildcard}, true}, {{CSPSource::NoWildcard, CSPSource::HasWildcard}, {CSPSource::HasWildcard, CSPSource::HasWildcard}, true}, // Four out of four possible wildcards. {{CSPSource::HasWildcard, CSPSource::HasWildcard}, {CSPSource::HasWildcard, CSPSource::HasWildcard}, true}, }; // There are different cases for wildcards but now also the second CSPSource // has a more specific path. for (const auto& test : cases) { CSPSource* returned = new CSPSource(csp.get(), "http", "example.com", 0, "/", test.a.hostDispotion, test.a.portDispotion); CSPSource* required = new CSPSource(csp.get(), "http", "example.com", 0, "/", test.b.hostDispotion, test.b.portDispotion); EXPECT_EQ(required->subsumes(returned), test.expected); // Wildcards should not matter when required csp is stricter than returned // csp. CSPSource* required2 = new CSPSource(csp.get(), "https", "example.com", 0, "/", test.b.hostDispotion, test.b.portDispotion); EXPECT_FALSE(required2->subsumes(returned)); } } TEST_F(CSPSourceTest, SchemesOnlySubsumes) { struct TestCase { String aScheme; String bScheme; bool expected; } cases[] = { // HTTP {"http", "http", true}, {"http", "https", false}, {"https", "http", true}, {"https", "https", true}, // WSS {"ws", "ws", true}, {"ws", "wss", false}, {"wss", "ws", true}, {"wss", "wss", true}, // Unequal {"ws", "http", false}, {"http", "ws", false}, {"http", "about", false}, }; for (const auto& test : cases) { CSPSource* returned = new CSPSource(csp.get(), test.aScheme, "example.com", 0, "/", CSPSource::NoWildcard, CSPSource::NoWildcard); CSPSource* required = new CSPSource(csp.get(), test.bScheme, "example.com", 0, "/", CSPSource::NoWildcard, CSPSource::NoWildcard); EXPECT_EQ(required->subsumes(returned), test.expected); } } TEST_F(CSPSourceTest, IsSimilar) { struct Source { const char* scheme; const char* host; const char* path; const int port; }; struct TestCase { const Source a; const Source b; bool isSimilar; } cases[] = { // Similar {{"http", "example.com", "/", 0}, {"http", "example.com", "/", 0}, true}, // Schemes {{"https", "example.com", "/", 0}, {"https", "example.com", "/", 0}, true}, {{"https", "example.com", "/", 0}, {"http", "example.com", "/", 0}, true}, {{"ws", "example.com", "/", 0}, {"wss", "example.com", "/", 0}, true}, // Ports {{"http", "example.com", "/", 90}, {"http", "example.com", "/", 90}, true}, {{"wss", "example.com", "/", 0}, {"wss", "example.com", "/", 0}, true}, // use default port {{"http", "example.com", "/", 80}, {"http", "example.com", "/", 0}, true}, // Paths {{"http", "example.com", "/", 0}, {"http", "example.com", "/1.html", 0}, true}, {{"http", "example.com", "/", 0}, {"http", "example.com", "", 0}, true}, {{"http", "example.com", "/", 0}, {"http", "example.com", "/a/b/", 0}, true}, {{"http", "example.com", "/a/", 0}, {"http", "example.com", "/a/", 0}, true}, {{"http", "example.com", "/a/", 0}, {"http", "example.com", "/a/b/", 0}, true}, {{"http", "example.com", "/a/", 0}, {"http", "example.com", "/a/b/1.html", 0}, true}, {{"http", "example.com", "/1.html", 0}, {"http", "example.com", "/1.html", 0}, true}, // Mixed {{"http", "example.com", "/1.html", 90}, {"http", "example.com", "/", 90}, true}, {{"https", "example.com", "/", 0}, {"http", "example.com", "/", 0}, true}, {{"http", "example.com", "/a/", 90}, {"https", "example.com", "", 90}, true}, {{"wss", "example.com", "/a/", 90}, {"ws", "example.com", "/a/b/", 90}, true}, {{"https", "example.com", "/a/", 90}, {"https", "example.com", "/a/b/", 90}, true}, // Not Similar {{"http", "example.com", "/a/", 0}, {"https", "example.com", "", 90}, false}, {{"https", "example.com", "/", 0}, {"https", "example.com", "/", 90}, false}, {{"http", "example.com", "/", 0}, {"http", "another.com", "/", 0}, false}, {{"wss", "example.com", "/", 0}, {"http", "example.com", "/", 0}, false}, {{"wss", "example.com", "/", 0}, {"about", "example.com", "/", 0}, false}, {{"http", "example.com", "/", 0}, {"about", "example.com", "/", 0}, false}, {{"http", "example.com", "/1.html", 0}, {"http", "example.com", "/2.html", 0}, false}, {{"http", "example.com", "/a/1.html", 0}, {"http", "example.com", "/a/b/", 0}, false}, {{"http", "example.com", "/", 443}, {"about", "example.com", "/", 800}, false}, }; for (const auto& test : cases) { CSPSource* returned = new CSPSource( csp.get(), test.a.scheme, test.a.host, test.a.port, test.a.path, CSPSource::NoWildcard, CSPSource::NoWildcard); CSPSource* required = new CSPSource( csp.get(), test.b.scheme, test.b.host, test.b.port, test.b.path, CSPSource::NoWildcard, CSPSource::NoWildcard); EXPECT_EQ(returned->isSimilar(required), test.isSimilar); // Verify the same test with a and b swapped. EXPECT_EQ(required->isSimilar(returned), test.isSimilar); } } TEST_F(CSPSourceTest, FirstSubsumesSecond) { struct Source { const char* scheme; const char* host; const int port; const char* path; }; struct TestCase { const Source sourceB; String schemeA; bool expected; } cases[] = { // Subsumed. {{"http", "example.com", 0, "/"}, "http", true}, {{"http", "example.com", 0, "/page.html"}, "http", true}, {{"http", "second-example.com", 80, "/"}, "http", true}, {{"https", "second-example.com", 0, "/"}, "http", true}, {{"http", "second-example.com", 0, "/page.html"}, "http", true}, {{"https", "second-example.com", 80, "/page.html"}, "http", true}, {{"https", "second-example.com", 0, "/"}, "https", true}, {{"https", "second-example.com", 0, "/page.html"}, "https", true}, {{"http", "example.com", 900, "/"}, "http", true}, // NOT subsumed. {{"http", "second-example.com", 0, "/"}, "wss", false}, {{"http", "non-example.com", 900, "/"}, "http", false}, {{"http", "second-example.com", 0, "/"}, "https", false}, }; CSPSource* noWildcards = new CSPSource(csp.get(), "http", "example.com", 0, "/", CSPSource::NoWildcard, CSPSource::NoWildcard); CSPSource* hostWildcard = new CSPSource(csp.get(), "http", "third-example.com", 0, "/", CSPSource::HasWildcard, CSPSource::NoWildcard); CSPSource* portWildcard = new CSPSource(csp.get(), "http", "third-example.com", 0, "/", CSPSource::NoWildcard, CSPSource::HasWildcard); CSPSource* bothWildcards = new CSPSource(csp.get(), "http", "third-example.com", 0, "/", CSPSource::HasWildcard, CSPSource::HasWildcard); CSPSource* httpOnly = new CSPSource(csp.get(), "http", "", 0, "", CSPSource::NoWildcard, CSPSource::NoWildcard); CSPSource* httpsOnly = new CSPSource(csp.get(), "https", "", 0, "", CSPSource::NoWildcard, CSPSource::NoWildcard); for (const auto& test : cases) { // Setup default vectors. HeapVector<Member<CSPSource>> listA; HeapVector<Member<CSPSource>> listB; listB.append(noWildcards); // Empty `listA` implies `none` is allowed. EXPECT_FALSE(CSPSource::firstSubsumesSecond(listA, listB)); listA.append(noWildcards); // Add CSPSources based on the current test. listB.append(new CSPSource(csp.get(), test.sourceB.scheme, test.sourceB.host, 0, test.sourceB.path, CSPSource::NoWildcard, CSPSource::NoWildcard)); listA.append(new CSPSource(csp.get(), test.schemeA, "second-example.com", 0, "/", CSPSource::NoWildcard, CSPSource::NoWildcard)); // listB contains: ["http://example.com/", test.listB] // listA contains: ["http://example.com/", // test.schemeA + "://second-example.com/"] EXPECT_EQ(test.expected, CSPSource::firstSubsumesSecond(listA, listB)); // If we add another source to `listB` with a host wildcard, // then the result should definitely be false. listB.append(hostWildcard); // If we add another source to `listA` with a port wildcard, // it does not make `listB` to be subsumed under `listA`. listB.append(portWildcard); EXPECT_FALSE(CSPSource::firstSubsumesSecond(listA, listB)); // If however we add another source to `listA` with both wildcards, // that CSPSource is subsumed, so the answer should be as expected // before. listA.append(bothWildcards); EXPECT_EQ(test.expected, CSPSource::firstSubsumesSecond(listA, listB)); // If we add a scheme-source expression of 'https' to `listB`, then it // should not be subsumed. listB.append(httpsOnly); EXPECT_FALSE(CSPSource::firstSubsumesSecond(listA, listB)); // If we add a scheme-source expression of 'http' to `listA`, then it should // subsume all current epxression in `listB`. listA.append(httpOnly); EXPECT_TRUE(CSPSource::firstSubsumesSecond(listA, listB)); } } } // namespace blink
; Z88 Small C+ Graphics Functions ; Draw a circle on the Z88 map ; Adapted from my Spectrum Routine ; (C) 1995-1998 D.J.Morris ; ; ZX81 version ; Non IY dependent (self modifying code) ; A' isn't used ; ; $Id: dcircle2.asm,v 1.6 2017-01-02 21:51:24 aralbrec Exp $ ; PUBLIC draw_circle DEFVARS 0 { x0 ds.b 1 y0 ds.b 1 radius ds.b 1 scale ds.b 1 cx ds.b 1 da ds.b 1 } .asave defb 0 ;ix points to table on stack (above) ;Entry: ; b=x0 c=y0, d=radius, e=scale factor ; ix=plot routine .draw_circle ld (plt+1),ix ld ix,-6 ;create buffer on stack add ix,sp ld sp,ix ld (ix+x0),b ld (ix+y0),c ld (ix+radius),d ld (ix+scale),e ;step factor - usually 1 call l9900 ld hl,6 add hl,sp ld sp,hl ret ;Line 9900 .l9900 ld (ix+cx),0 srl d ld (ix+da),d ;Line 9905 .l9905 ld a,(ix+cx) cp (ix+radius) ret nc ;Line 9910 ld a,(ix+da) and a jp p,l9915 add a,(ix+radius) ld (ix+da),a ld a,(ix+radius) sub (ix+scale) ld (ix+radius),a ;Line 9915 .l9915 ld a,(ix+da) dec a sub (ix+cx) ld (ix+da),a .l9920 ld a,(ix+y0) add a,(ix+radius) ld l,a ld a,(asave) push af ld a,l ld (asave),a pop af ld a,(ix+x0) add a,(ix+cx) ld h,a call doplot push af ld a,(asave) ld l,a pop af ld (asave),a ld a,(ix+x0) sub (ix+cx) ld h,a call doplot ld a,(ix+y0) sub (ix+radius) ld l,a ld a,(asave) push af ld a,l ld (asave),a pop af ld a,(ix+x0) add a,(ix+cx) ld h,a call doplot push af ld a,(asave) ld l,a pop af ld (asave),a ld a,(ix+x0) sub (ix+cx) ld h,a call doplot ;Line 9925 ld a,(ix+y0) add a,(ix+cx) ld l,a ld a,(asave) push af ld a,l ld (asave),a pop af ld a,(ix+x0) add a,(ix+radius) ld h,a call doplot push af ld a,(asave) ld l,a pop af ld (asave),a ld a,(ix+x0) sub (ix+radius) ld h,a call doplot ld a,(ix+y0) sub (ix+cx) ld l,a ld a,(asave) push af ld a,l ld (asave),a pop af ld a,(ix+x0) add a,(ix+radius) ld h,a call doplot push af ld a,(asave) ld l,a pop af ld (asave),a ld a,(ix+x0) sub (ix+radius) ld h,a call doplot ;Line 9930 ld a,(ix+cx) add a,(ix+scale) ld (ix+cx),a jp l9905 ;Entry to my plot is the same as for the z88 plot - very convenient! .doplot ret c .plt jp 0
; Copyright (c) 2010 The Chromium Authors. All rights reserved. ; Use of this source code is governed by a BSD-style license that can be ; found in the LICENSE file. ; ; Tag the exception handler as an SEH handler in case the executable ; is linked with /SAFESEH (which is the default). ; ; MASM 8.0 inserts an additional leading underscore in front of names ; and this is an attempted fix until we understand why. ; MASM 10.0 fixed this. IF @version LT 800 OR @version GE 1000 _ExceptionBarrierHandler PROTO .SAFESEH _ExceptionBarrierHandler _ExceptionBarrierReportOnlyModuleHandler PROTO .SAFESEH _ExceptionBarrierReportOnlyModuleHandler _ExceptionBarrierCallCustomHandler PROTO .SAFESEH _ExceptionBarrierCallCustomHandler ELSE ExceptionBarrierHandler PROTO .SAFESEH ExceptionBarrierHandler ExceptionBarrierReportOnlyModuleHandler PROTO .SAFESEH ExceptionBarrierReportOnlyModuleHandler ExceptionBarrierCallCustomHandler PROTO .SAFESEH ExceptionBarrierCallCustomHandler ENDIF .586 .MODEL FLAT, STDCALL ASSUME FS:NOTHING .CODE ; extern "C" void WINAPI RegisterExceptionRecord( ; EXCEPTION_REGISTRATION *registration, ; ExceptionHandlerFunc func); RegisterExceptionRecord PROC registration:DWORD, func:DWORD OPTION PROLOGUE:None OPTION EPILOGUE:None mov edx, DWORD PTR [esp + 4] ; edx is registration mov eax, DWORD PTR [esp + 8] ; eax is func mov DWORD PTR [edx + 4], eax mov eax, FS:[0] mov DWORD PTR [edx], eax mov FS:[0], edx ret 8 RegisterExceptionRecord ENDP ; extern "C" void UnregisterExceptionRecord( ; EXCEPTION_REGISTRATION *registration); UnregisterExceptionRecord PROC registration:DWORD OPTION PROLOGUE:None OPTION EPILOGUE:None mov edx, DWORD PTR [esp + 4] mov eax, [edx] mov FS:[0], eax ret 4 UnregisterExceptionRecord ENDP END
/* * PURPOSE: * Class representing an articulated rigid body. Stores the body's * current state, allows forces and torques to be set, handles * timestepping and implements Featherstone's algorithm. * * COPYRIGHT: * Copyright (C) Stephen Thompson, <stephen@solarflare.org.uk>, 2011-2013 * Portions written By Erwin Coumans: connection to LCP solver, various multibody constraints, replacing Eigen math library by Bullet LinearMath and a dedicated 6x6 matrix inverse (solveImatrix) * Portions written By Jakub Stepien: support for multi-DOF constraints, introduction of spatial algebra and several other improvements This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "btMultiBody.h" #include "btMultiBodyLink.h" #include "btMultiBodyLinkCollider.h" #include "btMultiBodyJointFeedback.h" #include "LinearMath/btTransformUtil.h" #include "LinearMath/btSerializer.h" //#include "Bullet3Common/b3Logging.h" // #define INCLUDE_GYRO_TERM namespace { const btScalar SLEEP_EPSILON = btScalar(0.05); // this is a squared velocity (m^2 s^-2) const btScalar SLEEP_TIMEOUT = btScalar(2); // in seconds } // namespace void btMultiBody::spatialTransform(const btMatrix3x3 &rotation_matrix, // rotates vectors in 'from' frame to vectors in 'to' frame const btVector3 &displacement, // vector from origin of 'from' frame to origin of 'to' frame, in 'to' coordinates const btVector3 &top_in, // top part of input vector const btVector3 &bottom_in, // bottom part of input vector btVector3 &top_out, // top part of output vector btVector3 &bottom_out) // bottom part of output vector { top_out = rotation_matrix * top_in; bottom_out = -displacement.cross(top_out) + rotation_matrix * bottom_in; } namespace { #if 0 void InverseSpatialTransform(const btMatrix3x3 &rotation_matrix, const btVector3 &displacement, const btVector3 &top_in, const btVector3 &bottom_in, btVector3 &top_out, btVector3 &bottom_out) { top_out = rotation_matrix.transpose() * top_in; bottom_out = rotation_matrix.transpose() * (bottom_in + displacement.cross(top_in)); } btScalar SpatialDotProduct(const btVector3 &a_top, const btVector3 &a_bottom, const btVector3 &b_top, const btVector3 &b_bottom) { return a_bottom.dot(b_top) + a_top.dot(b_bottom); } void SpatialCrossProduct(const btVector3 &a_top, const btVector3 &a_bottom, const btVector3 &b_top, const btVector3 &b_bottom, btVector3 &top_out, btVector3 &bottom_out) { top_out = a_top.cross(b_top); bottom_out = a_bottom.cross(b_top) + a_top.cross(b_bottom); } #endif } // namespace // // Implementation of class btMultiBody // btMultiBody::btMultiBody(int n_links, btScalar mass, const btVector3 &inertia, bool fixedBase, bool canSleep, bool /*deprecatedUseMultiDof*/) : m_baseCollider(0), m_baseName(0), m_basePos(0, 0, 0), m_baseQuat(0, 0, 0, 1), m_baseMass(mass), m_baseInertia(inertia), m_fixedBase(fixedBase), m_awake(true), m_canSleep(canSleep), m_canWakeup(true), m_sleepTimer(0), m_userObjectPointer(0), m_userIndex2(-1), m_userIndex(-1), m_companionId(-1), m_linearDamping(0.04f), m_angularDamping(0.04f), m_useGyroTerm(true), m_maxAppliedImpulse(1000.f), m_maxCoordinateVelocity(100.f), m_hasSelfCollision(true), __posUpdated(false), m_dofCount(0), m_posVarCnt(0), m_useRK4(false), m_useGlobalVelocities(false), m_internalNeedsJointFeedback(false) { m_cachedInertiaTopLeft.setValue(0, 0, 0, 0, 0, 0, 0, 0, 0); m_cachedInertiaTopRight.setValue(0, 0, 0, 0, 0, 0, 0, 0, 0); m_cachedInertiaLowerLeft.setValue(0, 0, 0, 0, 0, 0, 0, 0, 0); m_cachedInertiaLowerRight.setValue(0, 0, 0, 0, 0, 0, 0, 0, 0); m_cachedInertiaValid = false; m_links.resize(n_links); m_matrixBuf.resize(n_links + 1); m_baseForce.setValue(0, 0, 0); m_baseTorque.setValue(0, 0, 0); clearConstraintForces(); clearForcesAndTorques(); } btMultiBody::~btMultiBody() { } void btMultiBody::setupFixed(int i, btScalar mass, const btVector3 &inertia, int parent, const btQuaternion &rotParentToThis, const btVector3 &parentComToThisPivotOffset, const btVector3 &thisPivotToThisComOffset, bool /*deprecatedDisableParentCollision*/) { m_links[i].m_mass = mass; m_links[i].m_inertiaLocal = inertia; m_links[i].m_parent = parent; m_links[i].setAxisTop(0, 0., 0., 0.); m_links[i].setAxisBottom(0, btVector3(0, 0, 0)); m_links[i].m_zeroRotParentToThis = rotParentToThis; m_links[i].m_dVector = thisPivotToThisComOffset; m_links[i].m_eVector = parentComToThisPivotOffset; m_links[i].m_jointType = btMultibodyLink::eFixed; m_links[i].m_dofCount = 0; m_links[i].m_posVarCount = 0; m_links[i].m_flags |= BT_MULTIBODYLINKFLAGS_DISABLE_PARENT_COLLISION; m_links[i].updateCacheMultiDof(); updateLinksDofOffsets(); } void btMultiBody::setupPrismatic(int i, btScalar mass, const btVector3 &inertia, int parent, const btQuaternion &rotParentToThis, const btVector3 &jointAxis, const btVector3 &parentComToThisPivotOffset, const btVector3 &thisPivotToThisComOffset, bool disableParentCollision) { m_dofCount += 1; m_posVarCnt += 1; m_links[i].m_mass = mass; m_links[i].m_inertiaLocal = inertia; m_links[i].m_parent = parent; m_links[i].m_zeroRotParentToThis = rotParentToThis; m_links[i].setAxisTop(0, 0., 0., 0.); m_links[i].setAxisBottom(0, jointAxis); m_links[i].m_eVector = parentComToThisPivotOffset; m_links[i].m_dVector = thisPivotToThisComOffset; m_links[i].m_cachedRotParentToThis = rotParentToThis; m_links[i].m_jointType = btMultibodyLink::ePrismatic; m_links[i].m_dofCount = 1; m_links[i].m_posVarCount = 1; m_links[i].m_jointPos[0] = 0.f; m_links[i].m_jointTorque[0] = 0.f; if (disableParentCollision) m_links[i].m_flags |= BT_MULTIBODYLINKFLAGS_DISABLE_PARENT_COLLISION; // m_links[i].updateCacheMultiDof(); updateLinksDofOffsets(); } void btMultiBody::setupRevolute(int i, btScalar mass, const btVector3 &inertia, int parent, const btQuaternion &rotParentToThis, const btVector3 &jointAxis, const btVector3 &parentComToThisPivotOffset, const btVector3 &thisPivotToThisComOffset, bool disableParentCollision) { m_dofCount += 1; m_posVarCnt += 1; m_links[i].m_mass = mass; m_links[i].m_inertiaLocal = inertia; m_links[i].m_parent = parent; m_links[i].m_zeroRotParentToThis = rotParentToThis; m_links[i].setAxisTop(0, jointAxis); m_links[i].setAxisBottom(0, jointAxis.cross(thisPivotToThisComOffset)); m_links[i].m_dVector = thisPivotToThisComOffset; m_links[i].m_eVector = parentComToThisPivotOffset; m_links[i].m_jointType = btMultibodyLink::eRevolute; m_links[i].m_dofCount = 1; m_links[i].m_posVarCount = 1; m_links[i].m_jointPos[0] = 0.f; m_links[i].m_jointTorque[0] = 0.f; if (disableParentCollision) m_links[i].m_flags |= BT_MULTIBODYLINKFLAGS_DISABLE_PARENT_COLLISION; // m_links[i].updateCacheMultiDof(); // updateLinksDofOffsets(); } void btMultiBody::setupSpherical(int i, btScalar mass, const btVector3 &inertia, int parent, const btQuaternion &rotParentToThis, const btVector3 &parentComToThisPivotOffset, const btVector3 &thisPivotToThisComOffset, bool disableParentCollision) { m_dofCount += 3; m_posVarCnt += 4; m_links[i].m_mass = mass; m_links[i].m_inertiaLocal = inertia; m_links[i].m_parent = parent; m_links[i].m_zeroRotParentToThis = rotParentToThis; m_links[i].m_dVector = thisPivotToThisComOffset; m_links[i].m_eVector = parentComToThisPivotOffset; m_links[i].m_jointType = btMultibodyLink::eSpherical; m_links[i].m_dofCount = 3; m_links[i].m_posVarCount = 4; m_links[i].setAxisTop(0, 1.f, 0.f, 0.f); m_links[i].setAxisTop(1, 0.f, 1.f, 0.f); m_links[i].setAxisTop(2, 0.f, 0.f, 1.f); m_links[i].setAxisBottom(0, m_links[i].getAxisTop(0).cross(thisPivotToThisComOffset)); m_links[i].setAxisBottom(1, m_links[i].getAxisTop(1).cross(thisPivotToThisComOffset)); m_links[i].setAxisBottom(2, m_links[i].getAxisTop(2).cross(thisPivotToThisComOffset)); m_links[i].m_jointPos[0] = m_links[i].m_jointPos[1] = m_links[i].m_jointPos[2] = 0.f; m_links[i].m_jointPos[3] = 1.f; m_links[i].m_jointTorque[0] = m_links[i].m_jointTorque[1] = m_links[i].m_jointTorque[2] = 0.f; if (disableParentCollision) m_links[i].m_flags |= BT_MULTIBODYLINKFLAGS_DISABLE_PARENT_COLLISION; // m_links[i].updateCacheMultiDof(); // updateLinksDofOffsets(); } void btMultiBody::setupPlanar(int i, btScalar mass, const btVector3 &inertia, int parent, const btQuaternion &rotParentToThis, const btVector3 &rotationAxis, const btVector3 &parentComToThisComOffset, bool disableParentCollision) { m_dofCount += 3; m_posVarCnt += 3; m_links[i].m_mass = mass; m_links[i].m_inertiaLocal = inertia; m_links[i].m_parent = parent; m_links[i].m_zeroRotParentToThis = rotParentToThis; m_links[i].m_dVector.setZero(); m_links[i].m_eVector = parentComToThisComOffset; // btVector3 vecNonParallelToRotAxis(1, 0, 0); if (rotationAxis.normalized().dot(vecNonParallelToRotAxis) > 0.999) vecNonParallelToRotAxis.setValue(0, 1, 0); // m_links[i].m_jointType = btMultibodyLink::ePlanar; m_links[i].m_dofCount = 3; m_links[i].m_posVarCount = 3; btVector3 n = rotationAxis.normalized(); m_links[i].setAxisTop(0, n[0], n[1], n[2]); m_links[i].setAxisTop(1, 0, 0, 0); m_links[i].setAxisTop(2, 0, 0, 0); m_links[i].setAxisBottom(0, 0, 0, 0); btVector3 cr = m_links[i].getAxisTop(0).cross(vecNonParallelToRotAxis); m_links[i].setAxisBottom(1, cr[0], cr[1], cr[2]); cr = m_links[i].getAxisBottom(1).cross(m_links[i].getAxisTop(0)); m_links[i].setAxisBottom(2, cr[0], cr[1], cr[2]); m_links[i].m_jointPos[0] = m_links[i].m_jointPos[1] = m_links[i].m_jointPos[2] = 0.f; m_links[i].m_jointTorque[0] = m_links[i].m_jointTorque[1] = m_links[i].m_jointTorque[2] = 0.f; if (disableParentCollision) m_links[i].m_flags |= BT_MULTIBODYLINKFLAGS_DISABLE_PARENT_COLLISION; // m_links[i].updateCacheMultiDof(); // updateLinksDofOffsets(); m_links[i].setAxisBottom(1, m_links[i].getAxisBottom(1).normalized()); m_links[i].setAxisBottom(2, m_links[i].getAxisBottom(2).normalized()); } void btMultiBody::finalizeMultiDof() { m_deltaV.resize(0); m_deltaV.resize(6 + m_dofCount); m_realBuf.resize(6 + m_dofCount + m_dofCount * m_dofCount + 6 + m_dofCount); //m_dofCount for joint-space vels + m_dofCount^2 for "D" matrices + delta-pos vector (6 base "vels" + joint "vels") m_vectorBuf.resize(2 * m_dofCount); //two 3-vectors (i.e. one six-vector) for each system dof ("h" matrices) m_matrixBuf.resize(m_links.size() + 1); for (int i = 0; i < m_vectorBuf.size(); i++) { m_vectorBuf[i].setValue(0, 0, 0); } updateLinksDofOffsets(); } int btMultiBody::getParent(int link_num) const { return m_links[link_num].m_parent; } btScalar btMultiBody::getLinkMass(int i) const { return m_links[i].m_mass; } const btVector3 &btMultiBody::getLinkInertia(int i) const { return m_links[i].m_inertiaLocal; } btScalar btMultiBody::getJointPos(int i) const { return m_links[i].m_jointPos[0]; } btScalar btMultiBody::getJointVel(int i) const { return m_realBuf[6 + m_links[i].m_dofOffset]; } btScalar *btMultiBody::getJointPosMultiDof(int i) { return &m_links[i].m_jointPos[0]; } btScalar *btMultiBody::getJointVelMultiDof(int i) { return &m_realBuf[6 + m_links[i].m_dofOffset]; } const btScalar *btMultiBody::getJointPosMultiDof(int i) const { return &m_links[i].m_jointPos[0]; } const btScalar *btMultiBody::getJointVelMultiDof(int i) const { return &m_realBuf[6 + m_links[i].m_dofOffset]; } void btMultiBody::setJointPos(int i, btScalar q) { m_links[i].m_jointPos[0] = q; m_links[i].updateCacheMultiDof(); } void btMultiBody::setJointPosMultiDof(int i, const double *q) { for (int pos = 0; pos < m_links[i].m_posVarCount; ++pos) m_links[i].m_jointPos[pos] = (btScalar)q[pos]; m_links[i].updateCacheMultiDof(); } void btMultiBody::setJointPosMultiDof(int i, const float *q) { for (int pos = 0; pos < m_links[i].m_posVarCount; ++pos) m_links[i].m_jointPos[pos] = (btScalar)q[pos]; m_links[i].updateCacheMultiDof(); } void btMultiBody::setJointVel(int i, btScalar qdot) { m_realBuf[6 + m_links[i].m_dofOffset] = qdot; } void btMultiBody::setJointVelMultiDof(int i, const double *qdot) { for (int dof = 0; dof < m_links[i].m_dofCount; ++dof) m_realBuf[6 + m_links[i].m_dofOffset + dof] = (btScalar)qdot[dof]; } void btMultiBody::setJointVelMultiDof(int i, const float* qdot) { for (int dof = 0; dof < m_links[i].m_dofCount; ++dof) m_realBuf[6 + m_links[i].m_dofOffset + dof] = (btScalar)qdot[dof]; } const btVector3 &btMultiBody::getRVector(int i) const { return m_links[i].m_cachedRVector; } const btQuaternion &btMultiBody::getParentToLocalRot(int i) const { return m_links[i].m_cachedRotParentToThis; } btVector3 btMultiBody::localPosToWorld(int i, const btVector3 &local_pos) const { btAssert(i >= -1); btAssert(i < m_links.size()); if ((i < -1) || (i >= m_links.size())) { return btVector3(SIMD_INFINITY, SIMD_INFINITY, SIMD_INFINITY); } btVector3 result = local_pos; while (i != -1) { // 'result' is in frame i. transform it to frame parent(i) result += getRVector(i); result = quatRotate(getParentToLocalRot(i).inverse(), result); i = getParent(i); } // 'result' is now in the base frame. transform it to world frame result = quatRotate(getWorldToBaseRot().inverse(), result); result += getBasePos(); return result; } btVector3 btMultiBody::worldPosToLocal(int i, const btVector3 &world_pos) const { btAssert(i >= -1); btAssert(i < m_links.size()); if ((i < -1) || (i >= m_links.size())) { return btVector3(SIMD_INFINITY, SIMD_INFINITY, SIMD_INFINITY); } if (i == -1) { // world to base return quatRotate(getWorldToBaseRot(), (world_pos - getBasePos())); } else { // find position in parent frame, then transform to current frame return quatRotate(getParentToLocalRot(i), worldPosToLocal(getParent(i), world_pos)) - getRVector(i); } } btVector3 btMultiBody::localDirToWorld(int i, const btVector3 &local_dir) const { btAssert(i >= -1); btAssert(i < m_links.size()); if ((i < -1) || (i >= m_links.size())) { return btVector3(SIMD_INFINITY, SIMD_INFINITY, SIMD_INFINITY); } btVector3 result = local_dir; while (i != -1) { result = quatRotate(getParentToLocalRot(i).inverse(), result); i = getParent(i); } result = quatRotate(getWorldToBaseRot().inverse(), result); return result; } btVector3 btMultiBody::worldDirToLocal(int i, const btVector3 &world_dir) const { btAssert(i >= -1); btAssert(i < m_links.size()); if ((i < -1) || (i >= m_links.size())) { return btVector3(SIMD_INFINITY, SIMD_INFINITY, SIMD_INFINITY); } if (i == -1) { return quatRotate(getWorldToBaseRot(), world_dir); } else { return quatRotate(getParentToLocalRot(i), worldDirToLocal(getParent(i), world_dir)); } } btMatrix3x3 btMultiBody::localFrameToWorld(int i, const btMatrix3x3 &local_frame) const { btMatrix3x3 result = local_frame; btVector3 frameInWorld0 = localDirToWorld(i, local_frame.getColumn(0)); btVector3 frameInWorld1 = localDirToWorld(i, local_frame.getColumn(1)); btVector3 frameInWorld2 = localDirToWorld(i, local_frame.getColumn(2)); result.setValue(frameInWorld0[0], frameInWorld1[0], frameInWorld2[0], frameInWorld0[1], frameInWorld1[1], frameInWorld2[1], frameInWorld0[2], frameInWorld1[2], frameInWorld2[2]); return result; } #include <iostream> void btMultiBody::compTreeLinkVelocities(btVector3 *omega, btVector3 *vel) const { int num_links = getNumLinks(); // Calculates the velocities of each link (and the base) in its local frame const btQuaternion& base_rot = getWorldToBaseRot(); omega[0] = quatRotate(base_rot, getBaseOmega()); vel[0] = quatRotate(base_rot, getBaseVel()); // printf("joint 0 local omega = %.5f, %.5f, %.5f, vel = %.5f, %.5f, %.5f\n" // ,omega[0][0],omega[0][1],omega[0][2], // vel[0][0], vel[0][1],vel[0][2]); // num_links doesn't include root link, so we need "idx+1" for (int i = 0; i < num_links; ++i) { const btMultibodyLink& link = getLink(i); const int parent = link.m_parent; // std::cout <<"link " << i << " parent " << parent << std::endl; // transform parent vel into this frame, store in omega[i+1], vel[i+1] spatialTransform(btMatrix3x3(link.m_cachedRotParentToThis), link.m_cachedRVector, omega[parent + 1], vel[parent + 1], omega[i + 1], vel[i + 1]); // printf("joint %d local omega part 1 = %.5f, %.5f, %.5f, vel = %.5f, %.5f, %.5f\n", // i+1, omega[i + 1][0],omega[i + 1][1],omega[i + 1][2], // vel[i + 1][0], vel[i + 1][1],vel[i + 1][2]); // now add qidot * shat_i const btScalar* jointVel = getJointVelMultiDof(i); for (int dof = 0; dof < link.m_dofCount; ++dof) { omega[i + 1] += jointVel[dof] * link.getAxisTop(dof); vel[i + 1] += jointVel[dof] * link.getAxisBottom(dof); } // printf("joint %d local omega final = %.5f, %.5f, %.5f, vel = %.5f, %.5f, %.5f\n", // i+1, omega[i + 1][0],omega[i + 1][1],omega[i + 1][2], // vel[i + 1][0], vel[i + 1][1],vel[i + 1][2]); } // exit(1); } btScalar btMultiBody::getKineticEnergy() const { int num_links = getNumLinks(); // TODO: would be better not to allocate memory here btAlignedObjectArray<btVector3> omega; omega.resize(num_links + 1); btAlignedObjectArray<btVector3> vel; vel.resize(num_links + 1); compTreeLinkVelocities(&omega[0], &vel[0]); // we will do the factor of 0.5 at the end btScalar result = m_baseMass * vel[0].dot(vel[0]); result += omega[0].dot(m_baseInertia * omega[0]); for (int i = 0; i < num_links; ++i) { result += m_links[i].m_mass * vel[i + 1].dot(vel[i + 1]); result += omega[i + 1].dot(m_links[i].m_inertiaLocal * omega[i + 1]); } return 0.5f * result; } btVector3 btMultiBody::getAngularMomentum() const { int num_links = getNumLinks(); // TODO: would be better not to allocate memory here btAlignedObjectArray<btVector3> omega; omega.resize(num_links + 1); btAlignedObjectArray<btVector3> vel; vel.resize(num_links + 1); btAlignedObjectArray<btQuaternion> rot_from_world; rot_from_world.resize(num_links + 1); compTreeLinkVelocities(&omega[0], &vel[0]); rot_from_world[0] = m_baseQuat; btVector3 result = quatRotate(rot_from_world[0].inverse(), (m_baseInertia * omega[0])); for (int i = 0; i < num_links; ++i) { rot_from_world[i + 1] = m_links[i].m_cachedRotParentToThis * rot_from_world[m_links[i].m_parent + 1]; result += (quatRotate(rot_from_world[i + 1].inverse(), (m_links[i].m_inertiaLocal * omega[i + 1]))); } return result; } void btMultiBody::clearConstraintForces() { m_baseConstraintForce.setValue(0, 0, 0); m_baseConstraintTorque.setValue(0, 0, 0); for (int i = 0; i < getNumLinks(); ++i) { m_links[i].m_appliedConstraintForce.setValue(0, 0, 0); m_links[i].m_appliedConstraintTorque.setValue(0, 0, 0); } } void btMultiBody::clearForcesAndTorques() { m_baseForce.setValue(0, 0, 0); m_baseTorque.setValue(0, 0, 0); for (int i = 0; i < getNumLinks(); ++i) { m_links[i].m_appliedForce.setValue(0, 0, 0); m_links[i].m_appliedTorque.setValue(0, 0, 0); m_links[i].m_jointTorque[0] = m_links[i].m_jointTorque[1] = m_links[i].m_jointTorque[2] = m_links[i].m_jointTorque[3] = m_links[i].m_jointTorque[4] = m_links[i].m_jointTorque[5] = 0.f; } } void btMultiBody::clearVelocities() { for (int i = 0; i < 6 + getNumDofs(); ++i) { m_realBuf[i] = 0.f; } } void btMultiBody::addLinkForce(int i, const btVector3 &f) { m_links[i].m_appliedForce += f; } void btMultiBody::addLinkTorque(int i, const btVector3 &t) { m_links[i].m_appliedTorque += t; } void btMultiBody::addLinkConstraintForce(int i, const btVector3 &f) { m_links[i].m_appliedConstraintForce += f; } void btMultiBody::addLinkConstraintTorque(int i, const btVector3 &t) { m_links[i].m_appliedConstraintTorque += t; } void btMultiBody::addJointTorque(int i, btScalar Q) { m_links[i].m_jointTorque[0] += Q; } void btMultiBody::addJointTorqueMultiDof(int i, int dof, btScalar Q) { m_links[i].m_jointTorque[dof] += Q; } void btMultiBody::addJointTorqueMultiDof(int i, const btScalar *Q) { for (int dof = 0; dof < m_links[i].m_dofCount; ++dof) m_links[i].m_jointTorque[dof] = Q[dof]; } const btVector3 &btMultiBody::getLinkForce(int i) const { return m_links[i].m_appliedForce; } const btVector3 &btMultiBody::getLinkTorque(int i) const { return m_links[i].m_appliedTorque; } btScalar btMultiBody::getJointTorque(int i) const { return m_links[i].m_jointTorque[0]; } btScalar *btMultiBody::getJointTorqueMultiDof(int i) { return &m_links[i].m_jointTorque[0]; } inline btMatrix3x3 outerProduct(const btVector3 &v0, const btVector3 &v1) //renamed it from vecMulVecTranspose (http://en.wikipedia.org/wiki/Outer_product); maybe it should be moved to btVector3 like dot and cross? { btVector3 row0 = btVector3( v0.x() * v1.x(), v0.x() * v1.y(), v0.x() * v1.z()); btVector3 row1 = btVector3( v0.y() * v1.x(), v0.y() * v1.y(), v0.y() * v1.z()); btVector3 row2 = btVector3( v0.z() * v1.x(), v0.z() * v1.y(), v0.z() * v1.z()); btMatrix3x3 m(row0[0], row0[1], row0[2], row1[0], row1[1], row1[2], row2[0], row2[1], row2[2]); return m; } #define vecMulVecTranspose(v0, v1Transposed) outerProduct(v0, v1Transposed) // // #include <ID_test/BulletUtil.h> // #include <ID_test/BulletUtil.h> // #include "../../../examples/ExampleBrowser/ID_test/BulletUtil.h" void btMultiBody::computeAccelerationsArticulatedBodyAlgorithmMultiDof(btScalar dt, btAlignedObjectArray<btScalar> &scratch_r, btAlignedObjectArray<btVector3> &scratch_v, btAlignedObjectArray<btMatrix3x3> &scratch_m, bool isConstraintPass, bool jointFeedbackInWorldSpace, bool jointFeedbackInJointFrame) { // Implement Featherstone's algorithm to calculate joint accelerations (q_double_dot) // and the base linear & angular accelerations. // We apply damping forces in this routine as well as any external forces specified by the // caller (via addBaseForce etc). // output should point to an array of 6 + num_links reals. // Format is: 3 angular accelerations (in world frame), 3 linear accelerations (in world frame), // num_links joint acceleration values. // We added support for multi degree of freedom (multi dof) joints. // In addition we also can compute the joint reaction forces. This is performed in a second pass, // so that we can include the effect of the constraint solver forces (computed in the PGS LCP solver) m_internalNeedsJointFeedback = false; int num_links = getNumLinks(); const btScalar DAMPING_K1_LINEAR = m_linearDamping; const btScalar DAMPING_K2_LINEAR = m_linearDamping; const btScalar DAMPING_K1_ANGULAR = m_angularDamping; const btScalar DAMPING_K2_ANGULAR = m_angularDamping; const btVector3 base_vel = getBaseVel(); const btVector3 base_omega = getBaseOmega(); // Temporary matrices/vectors -- use scratch space from caller // so that we don't have to keep reallocating every frame scratch_r.resize(2 * m_dofCount + 7); //multidof? ("Y"s use it and it is used to store qdd) => 2 x m_dofCount scratch_v.resize(8 * num_links + 6); scratch_m.resize(4 * num_links + 4); //btScalar * r_ptr = &scratch_r[0]; btScalar *output = &scratch_r[m_dofCount]; // "output" holds the q_double_dot results btVector3 *v_ptr = &scratch_v[0]; // vhat_i (top = angular, bottom = linear part) btSpatialMotionVector *spatVel = (btSpatialMotionVector *)v_ptr; v_ptr += num_links * 2 + 2; // // zhat_i^A btSpatialForceVector *zeroAccSpatFrc = (btSpatialForceVector *)v_ptr; v_ptr += num_links * 2 + 2; // // chat_i (note NOT defined for the base) btSpatialMotionVector *spatCoriolisAcc = (btSpatialMotionVector *)v_ptr; v_ptr += num_links * 2; // // Ihat_i^A. btSymmetricSpatialDyad *spatInertia = (btSymmetricSpatialDyad *)&scratch_m[num_links + 1]; // Cached 3x3 rotation matrices from parent frame to this frame. btMatrix3x3 *rot_from_parent = &m_matrixBuf[0]; btMatrix3x3 *rot_from_world = &scratch_m[0]; // hhat_i, ahat_i // hhat is NOT stored for the base (but ahat is) btSpatialForceVector *h = (btSpatialForceVector *)(m_dofCount > 0 ? &m_vectorBuf[0] : 0); btSpatialMotionVector *spatAcc = (btSpatialMotionVector *)v_ptr; v_ptr += num_links * 2 + 2; // // Y_i, invD_i btScalar *invD = m_dofCount > 0 ? &m_realBuf[6 + m_dofCount] : 0; btScalar *Y = &scratch_r[0]; // //aux variables btSpatialMotionVector spatJointVel; //spatial velocity due to the joint motion (i.e. without predecessors' influence) btScalar D[36]; //"D" matrix; it's dofxdof for each body so asingle 6x6 D matrix will do btScalar invD_times_Y[6]; //D^{-1} * Y [dofxdof x dofx1 = dofx1] <=> D^{-1} * u; better moved to buffers since it is recalced in calcAccelerationDeltasMultiDof; num_dof of btScalar would cover all bodies btSpatialMotionVector result; //holds results of the SolveImatrix op; it is a spatial motion vector (accel) btScalar Y_minus_hT_a[6]; //Y - h^{T} * a; it's dofx1 for each body so a single 6x1 temp is enough btSpatialForceVector spatForceVecTemps[6]; //6 temporary spatial force vectors btSpatialTransformationMatrix fromParent; //spatial transform from parent to child btSymmetricSpatialDyad dyadTemp; //inertia matrix temp btSpatialTransformationMatrix fromWorld; fromWorld.m_trnVec.setZero(); ///////////////// // ptr to the joint accel part of the output btScalar *joint_accel = output + 6; // Start of the algorithm proper. // First 'upward' loop. // Combines CompTreeLinkVelocities and InitTreeLinks from Mirtich. rot_from_parent[0] = btMatrix3x3(m_baseQuat); //m_baseQuat assumed to be alias!? //create the vector of spatial velocity of the base by transforming global-coor linear and angular velocities into base-local coordinates spatVel[0].setVector(rot_from_parent[0] * base_omega, rot_from_parent[0] * base_vel); if (m_fixedBase) { zeroAccSpatFrc[0].setZero(); } else { const btVector3 &baseForce = isConstraintPass ? m_baseConstraintForce : m_baseForce; const btVector3 &baseTorque = isConstraintPass ? m_baseConstraintTorque : m_baseTorque; //external forces zeroAccSpatFrc[0].setVector(-(rot_from_parent[0] * baseTorque), -(rot_from_parent[0] * baseForce)); //adding damping terms (only) const btScalar linDampMult = 1., angDampMult = 1.; zeroAccSpatFrc[0].addVector(angDampMult * m_baseInertia * spatVel[0].getAngular() * (DAMPING_K1_ANGULAR + DAMPING_K2_ANGULAR * spatVel[0].getAngular().safeNorm()), linDampMult * m_baseMass * spatVel[0].getLinear() * (DAMPING_K1_LINEAR + DAMPING_K2_LINEAR * spatVel[0].getLinear().safeNorm())); // //p += vhat x Ihat vhat - done in a simpler way if (m_useGyroTerm) { zeroAccSpatFrc[0].addAngular(spatVel[0].getAngular().cross(m_baseInertia * spatVel[0].getAngular())); } // btVector3 tmp = m_baseMass * spatVel[0].getAngular().cross(spatVel[0].getLinear()); zeroAccSpatFrc[0].addLinear(m_baseMass * spatVel[0].getAngular().cross(spatVel[0].getLinear())); // printf("linear vel = %.6f, %.6f, %.6f\n", spatVel[0].getLinear().getX(), spatVel[0].getLinear().getY(), spatVel[0].getLinear().getZ()); // printf("ang vel = %.6f, %.6f, %.6f\n", spatVel[0].getAngular().getX(), spatVel[0].getAngular().getY(), spatVel[0].getAngular().getZ()); // printf("z.a.f linear part = %.6f, %.6f, %.6f\n", tmp.getX(), tmp.getY(), tmp.getZ()); // exit(1); } //init the spatial AB inertia (it has the simple form thanks to choosing local body frames origins at their COMs) spatInertia[0].setMatrix(btMatrix3x3(0, 0, 0, 0, 0, 0, 0, 0, 0), // btMatrix3x3(m_baseMass, 0, 0, 0, m_baseMass, 0, 0, 0, m_baseMass), // btMatrix3x3(m_baseInertia[0], 0, 0, 0, m_baseInertia[1], 0, 0, 0, m_baseInertia[2])); rot_from_world[0] = rot_from_parent[0]; // for (int i = 0; i < num_links; ++i) { const int parent = m_links[i].m_parent; rot_from_parent[i + 1] = btMatrix3x3(m_links[i].m_cachedRotParentToThis); rot_from_world[i + 1] = rot_from_parent[i + 1] * rot_from_world[parent + 1]; fromParent.m_rotMat = rot_from_parent[i + 1]; fromParent.m_trnVec = m_links[i].m_cachedRVector; fromWorld.m_rotMat = rot_from_world[i + 1]; fromParent.transform(spatVel[parent + 1], spatVel[i + 1]); // now set vhat_i to its true value by doing // vhat_i += qidot * shat_i if (!m_useGlobalVelocities) { spatJointVel.setZero(); for (int dof = 0; dof < m_links[i].m_dofCount; ++dof) spatJointVel += m_links[i].m_axes[dof] * getJointVelMultiDof(i)[dof]; // remember vhat_i is really vhat_p(i) (but in current frame) at this point => we need to add velocity across the inboard joint spatVel[i + 1] += spatJointVel; // // vhat_i is vhat_p(i) transformed to local coors + the velocity across the i-th inboard joint //spatVel[i+1] = fromParent * spatVel[parent+1] + spatJointVel; } else { fromWorld.transformRotationOnly(m_links[i].m_absFrameTotVelocity, spatVel[i + 1]); fromWorld.transformRotationOnly(m_links[i].m_absFrameLocVelocity, spatJointVel); } // we can now calculate chat_i spatVel[i + 1].cross(spatJointVel, spatCoriolisAcc[i]); // calculate zhat_i^A // //external forces btVector3 linkAppliedForce = isConstraintPass ? m_links[i].m_appliedConstraintForce : m_links[i].m_appliedForce; btVector3 linkAppliedTorque = isConstraintPass ? m_links[i].m_appliedConstraintTorque : m_links[i].m_appliedTorque; zeroAccSpatFrc[i + 1].setVector(-(rot_from_world[i + 1] * linkAppliedTorque), -(rot_from_world[i + 1] * linkAppliedForce)); #if 0 { b3Printf("stepVelocitiesMultiDof zeroAccSpatFrc[%d] linear:%f,%f,%f, angular:%f,%f,%f", i+1, zeroAccSpatFrc[i+1].m_topVec[0], zeroAccSpatFrc[i+1].m_topVec[1], zeroAccSpatFrc[i+1].m_topVec[2], zeroAccSpatFrc[i+1].m_bottomVec[0], zeroAccSpatFrc[i+1].m_bottomVec[1], zeroAccSpatFrc[i+1].m_bottomVec[2]); } #endif // //adding damping terms (only) btScalar linDampMult = 1., angDampMult = 1.; zeroAccSpatFrc[i + 1].addVector(angDampMult * m_links[i].m_inertiaLocal * spatVel[i + 1].getAngular() * (DAMPING_K1_ANGULAR + DAMPING_K2_ANGULAR * spatVel[i + 1].getAngular().safeNorm()), linDampMult * m_links[i].m_mass * spatVel[i + 1].getLinear() * (DAMPING_K1_LINEAR + DAMPING_K2_LINEAR * spatVel[i + 1].getLinear().safeNorm())); // calculate Ihat_i^A //init the spatial AB inertia (it has the simple form thanks to choosing local body frames origins at their COMs) spatInertia[i + 1].setMatrix(btMatrix3x3(0, 0, 0, 0, 0, 0, 0, 0, 0), // btMatrix3x3(m_links[i].m_mass, 0, 0, 0, m_links[i].m_mass, 0, 0, 0, m_links[i].m_mass), // btMatrix3x3(m_links[i].m_inertiaLocal[0], 0, 0, 0, m_links[i].m_inertiaLocal[1], 0, 0, 0, m_links[i].m_inertiaLocal[2])); // //p += vhat x Ihat vhat - done in a simpler way if (m_useGyroTerm) zeroAccSpatFrc[i + 1].addAngular(spatVel[i + 1].getAngular().cross(m_links[i].m_inertiaLocal * spatVel[i + 1].getAngular())); // zeroAccSpatFrc[i + 1].addLinear(m_links[i].m_mass * spatVel[i + 1].getAngular().cross(spatVel[i + 1].getLinear())); //btVector3 temp = m_links[i].m_mass * spatVel[i+1].getAngular().cross(spatVel[i+1].getLinear()); ////clamp parent's omega //btScalar parOmegaMod = temp.length(); //btScalar parOmegaModMax = 1000; //if(parOmegaMod > parOmegaModMax) // temp *= parOmegaModMax / parOmegaMod; //zeroAccSpatFrc[i+1].addLinear(temp); //printf("|zeroAccSpatFrc[%d]| = %.4f\n", i+1, temp.length()); //temp = spatCoriolisAcc[i].getLinear(); //printf("|spatCoriolisAcc[%d]| = %.4f\n", i+1, temp.length()); //printf("w[%d] = [%.4f %.4f %.4f]\n", i, vel_top_angular[i+1].x(), vel_top_angular[i+1].y(), vel_top_angular[i+1].z()); //printf("v[%d] = [%.4f %.4f %.4f]\n", i, vel_bottom_linear[i+1].x(), vel_bottom_linear[i+1].y(), vel_bottom_linear[i+1].z()); //printf("c[%d] = [%.4f %.4f %.4f]\n", i, coriolis_bottom_linear[i].x(), coriolis_bottom_linear[i].y(), coriolis_bottom_linear[i].z()); } // 'Downward' loop. // (part of TreeForwardDynamics in Mirtich.) for (int i = num_links - 1; i >= 0; --i) { const int parent = m_links[i].m_parent; fromParent.m_rotMat = rot_from_parent[i + 1]; fromParent.m_trnVec = m_links[i].m_cachedRVector; for (int dof = 0; dof < m_links[i].m_dofCount; ++dof) { btSpatialForceVector &hDof = h[m_links[i].m_dofOffset + dof]; // hDof = spatInertia[i + 1] * m_links[i].m_axes[dof]; // Y[m_links[i].m_dofOffset + dof] = m_links[i].m_jointTorque[dof] - m_links[i].m_axes[dof].dot(zeroAccSpatFrc[i + 1]) - spatCoriolisAcc[i].dot(hDof); } for (int dof = 0; dof < m_links[i].m_dofCount; ++dof) { btScalar *D_row = &D[dof * m_links[i].m_dofCount]; for (int dof2 = 0; dof2 < m_links[i].m_dofCount; ++dof2) { const btSpatialForceVector &hDof2 = h[m_links[i].m_dofOffset + dof2]; D_row[dof2] = m_links[i].m_axes[dof].dot(hDof2); } } btScalar *invDi = &invD[m_links[i].m_dofOffset * m_links[i].m_dofOffset]; switch (m_links[i].m_jointType) { case btMultibodyLink::ePrismatic: case btMultibodyLink::eRevolute: { if (D[0] >= SIMD_EPSILON) { invDi[0] = 1.0f / D[0]; } else { invDi[0] = 0; } break; } case btMultibodyLink::eSpherical: case btMultibodyLink::ePlanar: { const btMatrix3x3 D3x3(D[0], D[1], D[2], D[3], D[4], D[5], D[6], D[7], D[8]); const btMatrix3x3 invD3x3(D3x3.inverse()); //unroll the loop? for (int row = 0; row < 3; ++row) { for (int col = 0; col < 3; ++col) { invDi[row * 3 + col] = invD3x3[row][col]; } } break; } default: { } } //determine h*D^{-1} for (int dof = 0; dof < m_links[i].m_dofCount; ++dof) { spatForceVecTemps[dof].setZero(); for (int dof2 = 0; dof2 < m_links[i].m_dofCount; ++dof2) { const btSpatialForceVector &hDof2 = h[m_links[i].m_dofOffset + dof2]; // spatForceVecTemps[dof] += hDof2 * invDi[dof2 * m_links[i].m_dofCount + dof]; } } dyadTemp = spatInertia[i + 1]; //determine (h*D^{-1}) * h^{T} for (int dof = 0; dof < m_links[i].m_dofCount; ++dof) { const btSpatialForceVector &hDof = h[m_links[i].m_dofOffset + dof]; // dyadTemp -= symmetricSpatialOuterProduct(hDof, spatForceVecTemps[dof]); } fromParent.transformInverse(dyadTemp, spatInertia[parent + 1], btSpatialTransformationMatrix::Add); for (int dof = 0; dof < m_links[i].m_dofCount; ++dof) { invD_times_Y[dof] = 0.f; for (int dof2 = 0; dof2 < m_links[i].m_dofCount; ++dof2) { invD_times_Y[dof] += invDi[dof * m_links[i].m_dofCount + dof2] * Y[m_links[i].m_dofOffset + dof2]; } } spatForceVecTemps[0] = zeroAccSpatFrc[i + 1] + spatInertia[i + 1] * spatCoriolisAcc[i]; for (int dof = 0; dof < m_links[i].m_dofCount; ++dof) { const btSpatialForceVector &hDof = h[m_links[i].m_dofOffset + dof]; // spatForceVecTemps[0] += hDof * invD_times_Y[dof]; } fromParent.transformInverse(spatForceVecTemps[0], spatForceVecTemps[1]); zeroAccSpatFrc[parent + 1] += spatForceVecTemps[1]; } // Second 'upward' loop // (part of TreeForwardDynamics in Mirtich) if (m_fixedBase) { spatAcc[0].setZero(); } else { if (num_links > 0) { m_cachedInertiaValid = true; m_cachedInertiaTopLeft = spatInertia[0].m_topLeftMat; m_cachedInertiaTopRight = spatInertia[0].m_topRightMat; m_cachedInertiaLowerLeft = spatInertia[0].m_bottomLeftMat; m_cachedInertiaLowerRight = spatInertia[0].m_topLeftMat.transpose(); } solveImatrix(zeroAccSpatFrc[0], result); // printf("[debug] root link zero acc force linear part = %.6f, %.6f, %.6f\n", // zeroAccSpatFrc[0].getLinear().getX(), // zeroAccSpatFrc[0].getLinear().getY(), // zeroAccSpatFrc[0].getLinear().getZ()); spatAcc[0] = -result; // printf("[debug] solved accel linear part(should be 0) = %.6f, %.6f, %.6f\n", // spatAcc[0].getLinear().getX(), // spatAcc[0].getLinear().getY(), // spatAcc[0].getLinear().getZ()); } // now do the loop over the m_links for (int i = 0; i < num_links; ++i) { // qdd = D^{-1} * (Y - h^{T}*apar) = (S^{T}*I*S)^{-1} * (tau - S^{T}*I*cor - S^{T}*zeroAccFrc - S^{T}*I*apar) // a = apar + cor + Sqdd //or // qdd = D^{-1} * (Y - h^{T}*(apar+cor)) // a = apar + Sqdd const int parent = m_links[i].m_parent; fromParent.m_rotMat = rot_from_parent[i + 1]; fromParent.m_trnVec = m_links[i].m_cachedRVector; fromParent.transform(spatAcc[parent + 1], spatAcc[i + 1]); for (int dof = 0; dof < m_links[i].m_dofCount; ++dof) { const btSpatialForceVector &hDof = h[m_links[i].m_dofOffset + dof]; // Y_minus_hT_a[dof] = Y[m_links[i].m_dofOffset + dof] - spatAcc[i + 1].dot(hDof); } btScalar *invDi = &invD[m_links[i].m_dofOffset * m_links[i].m_dofOffset]; //D^{-1} * (Y - h^{T}*apar) mulMatrix(invDi, Y_minus_hT_a, m_links[i].m_dofCount, m_links[i].m_dofCount, m_links[i].m_dofCount, 1, &joint_accel[m_links[i].m_dofOffset]); spatAcc[i + 1] += spatCoriolisAcc[i]; for (int dof = 0; dof < m_links[i].m_dofCount; ++dof) spatAcc[i + 1] += m_links[i].m_axes[dof] * joint_accel[m_links[i].m_dofOffset + dof]; if (m_links[i].m_jointFeedback) { m_internalNeedsJointFeedback = true; btVector3 angularBotVec = (spatInertia[i + 1] * spatAcc[i + 1] + zeroAccSpatFrc[i + 1]).m_bottomVec; btVector3 linearTopVec = (spatInertia[i + 1] * spatAcc[i + 1] + zeroAccSpatFrc[i + 1]).m_topVec; if (jointFeedbackInJointFrame) { //shift the reaction forces to the joint frame //linear (force) component is the same //shift the angular (torque, moment) component using the relative position, m_links[i].m_dVector angularBotVec = angularBotVec - linearTopVec.cross(m_links[i].m_dVector); } if (jointFeedbackInWorldSpace) { if (isConstraintPass) { m_links[i].m_jointFeedback->m_reactionForces.m_bottomVec += m_links[i].m_cachedWorldTransform.getBasis() * angularBotVec; m_links[i].m_jointFeedback->m_reactionForces.m_topVec += m_links[i].m_cachedWorldTransform.getBasis() * linearTopVec; } else { m_links[i].m_jointFeedback->m_reactionForces.m_bottomVec = m_links[i].m_cachedWorldTransform.getBasis() * angularBotVec; m_links[i].m_jointFeedback->m_reactionForces.m_topVec = m_links[i].m_cachedWorldTransform.getBasis() * linearTopVec; } } else { if (isConstraintPass) { m_links[i].m_jointFeedback->m_reactionForces.m_bottomVec += angularBotVec; m_links[i].m_jointFeedback->m_reactionForces.m_topVec += linearTopVec; } else { m_links[i].m_jointFeedback->m_reactionForces.m_bottomVec = angularBotVec; m_links[i].m_jointFeedback->m_reactionForces.m_topVec = linearTopVec; } } } } // transform base accelerations back to the world frame. const btVector3 omegadot_out = rot_from_parent[0].transpose() * spatAcc[0].getAngular(); // test code, calculate base omega dot by my self { // btMatrix3x3 Ibody = cBulletUtil::AsDiagnoal(m_baseInertia); // btMatrix3x3 I0 = rot_from_world[0].transpose() * Ibody * rot_from_world[0]; // btVector3 omegadot_self = I0.inverse() * (base_omega.cross(I0 * base_omega)); // printf("self omega dot = %.6f, %.6f, %.6f\n", omegadot_self.getX(), omegadot_self.getY(), omegadot_self.getZ()); // printf("res omega dot = %.6f, %.6f, %.6f\n", omegadot_out.getX(), omegadot_out.getY(), omegadot_out.getZ()); // exit(1); } output[0] = omegadot_out[0]; output[1] = omegadot_out[1]; output[2] = omegadot_out[2]; // printf("omega dot output = %.6f, %.6f, %.6f\n", output[0], output[1], output[2]); const btVector3 vdot_out = rot_from_parent[0].transpose() * (spatAcc[0].getLinear() + spatVel[0].getAngular().cross(spatVel[0].getLinear())); output[3] = vdot_out[0]; output[4] = vdot_out[1]; output[5] = vdot_out[2]; ///////////////// //printf("q = ["); //printf("%.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f ", m_baseQuat.x(), m_baseQuat.y(), m_baseQuat.z(), m_baseQuat.w(), m_basePos.x(), m_basePos.y(), m_basePos.z()); //for(int link = 0; link < getNumLinks(); ++link) // for(int dof = 0; dof < m_links[link].m_dofCount; ++dof) // printf("%.6f ", m_links[link].m_jointPos[dof]); //printf("]\n"); //// //printf("qd = ["); //for(int dof = 0; dof < getNumDofs() + 6; ++dof) // printf("%.6f ", m_realBuf[dof]); //printf("]\n"); //printf("qdd = ["); //for(int dof = 0; dof < getNumDofs() + 6; ++dof) // printf("%.6f ", output[dof]); //printf("]\n"); ///////////////// // Final step: add the accelerations (times dt) to the velocities. if (!isConstraintPass) { if (dt > 0.) applyDeltaVeeMultiDof(output, dt); } ///// //btScalar angularThres = 1; //btScalar maxAngVel = 0.; //bool scaleDown = 1.; //for(int link = 0; link < m_links.size(); ++link) //{ // if(spatVel[link+1].getAngular().length() > maxAngVel) // { // maxAngVel = spatVel[link+1].getAngular().length(); // scaleDown = angularThres / spatVel[link+1].getAngular().length(); // break; // } //} //if(scaleDown != 1.) //{ // for(int link = 0; link < m_links.size(); ++link) // { // if(m_links[link].m_jointType == btMultibodyLink::eRevolute || m_links[link].m_jointType == btMultibodyLink::eSpherical) // { // for(int dof = 0; dof < m_links[link].m_dofCount; ++dof) // getJointVelMultiDof(link)[dof] *= scaleDown; // } // } //} ///// ///////////////////// if (m_useGlobalVelocities) { for (int i = 0; i < num_links; ++i) { const int parent = m_links[i].m_parent; //rot_from_parent[i+1] = btMatrix3x3(m_links[i].m_cachedRotParentToThis); /// <- done //rot_from_world[i+1] = rot_from_parent[i+1] * rot_from_world[parent+1]; /// <- done fromParent.m_rotMat = rot_from_parent[i + 1]; fromParent.m_trnVec = m_links[i].m_cachedRVector; fromWorld.m_rotMat = rot_from_world[i + 1]; // vhat_i = i_xhat_p(i) * vhat_p(i) fromParent.transform(spatVel[parent + 1], spatVel[i + 1]); //nice alternative below (using operator *) but it generates temps ///////////////////////////////////////////////////////////// // now set vhat_i to its true value by doing // vhat_i += qidot * shat_i spatJointVel.setZero(); for (int dof = 0; dof < m_links[i].m_dofCount; ++dof) spatJointVel += m_links[i].m_axes[dof] * getJointVelMultiDof(i)[dof]; // remember vhat_i is really vhat_p(i) (but in current frame) at this point => we need to add velocity across the inboard joint spatVel[i + 1] += spatJointVel; fromWorld.transformInverseRotationOnly(spatVel[i + 1], m_links[i].m_absFrameTotVelocity); fromWorld.transformInverseRotationOnly(spatJointVel, m_links[i].m_absFrameLocVelocity); } } // printf("[log] compute Accel is called, base omega = %.5f %.5f %.5f\n", // getBaseOmega().getX(), getBaseOmega().getY(), getBaseOmega().getZ()); } void btMultiBody::solveImatrix(const btVector3 &rhs_top, const btVector3 &rhs_bot, btScalar result[6]) const { int num_links = getNumLinks(); ///solve I * x = rhs, so the result = invI * rhs if (num_links == 0) { // in the case of 0 m_links (i.e. a plain rigid body, not a multibody) rhs * invI is easier if ((m_baseInertia[0] >= SIMD_EPSILON) && (m_baseInertia[1] >= SIMD_EPSILON) && (m_baseInertia[2] >= SIMD_EPSILON)) { result[0] = rhs_bot[0] / m_baseInertia[0]; result[1] = rhs_bot[1] / m_baseInertia[1]; result[2] = rhs_bot[2] / m_baseInertia[2]; } else { result[0] = 0; result[1] = 0; result[2] = 0; } if (m_baseMass >= SIMD_EPSILON) { result[3] = rhs_top[0] / m_baseMass; result[4] = rhs_top[1] / m_baseMass; result[5] = rhs_top[2] / m_baseMass; } else { result[3] = 0; result[4] = 0; result[5] = 0; } } else { if (!m_cachedInertiaValid) { for (int i = 0; i < 6; i++) { result[i] = 0.f; } return; } /// Special routine for calculating the inverse of a spatial inertia matrix ///the 6x6 matrix is stored as 4 blocks of 3x3 matrices btMatrix3x3 Binv = m_cachedInertiaTopRight.inverse() * -1.f; btMatrix3x3 tmp = m_cachedInertiaLowerRight * Binv; btMatrix3x3 invIupper_right = (tmp * m_cachedInertiaTopLeft + m_cachedInertiaLowerLeft).inverse(); tmp = invIupper_right * m_cachedInertiaLowerRight; btMatrix3x3 invI_upper_left = (tmp * Binv); btMatrix3x3 invI_lower_right = (invI_upper_left).transpose(); tmp = m_cachedInertiaTopLeft * invI_upper_left; tmp[0][0] -= 1.0; tmp[1][1] -= 1.0; tmp[2][2] -= 1.0; btMatrix3x3 invI_lower_left = (Binv * tmp); //multiply result = invI * rhs { btVector3 vtop = invI_upper_left * rhs_top; btVector3 tmp; tmp = invIupper_right * rhs_bot; vtop += tmp; btVector3 vbot = invI_lower_left * rhs_top; tmp = invI_lower_right * rhs_bot; vbot += tmp; result[0] = vtop[0]; result[1] = vtop[1]; result[2] = vtop[2]; result[3] = vbot[0]; result[4] = vbot[1]; result[5] = vbot[2]; } } } void btMultiBody::solveImatrix(const btSpatialForceVector &rhs, btSpatialMotionVector &result) const { int num_links = getNumLinks(); ///solve I * x = rhs, so the result = invI * rhs if (num_links == 0) { // in the case of 0 m_links (i.e. a plain rigid body, not a multibody) rhs * invI is easier if ((m_baseInertia[0] >= SIMD_EPSILON) && (m_baseInertia[1] >= SIMD_EPSILON) && (m_baseInertia[2] >= SIMD_EPSILON)) { result.setAngular(rhs.getAngular() / m_baseInertia); } else { result.setAngular(btVector3(0, 0, 0)); } if (m_baseMass >= SIMD_EPSILON) { result.setLinear(rhs.getLinear() / m_baseMass); } else { result.setLinear(btVector3(0, 0, 0)); } } else { /// Special routine for calculating the inverse of a spatial inertia matrix ///the 6x6 matrix is stored as 4 blocks of 3x3 matrices if (!m_cachedInertiaValid) { result.setLinear(btVector3(0, 0, 0)); result.setAngular(btVector3(0, 0, 0)); result.setVector(btVector3(0, 0, 0), btVector3(0, 0, 0)); return; } btMatrix3x3 Binv = m_cachedInertiaTopRight.inverse() * -1.f; btMatrix3x3 tmp = m_cachedInertiaLowerRight * Binv; btMatrix3x3 invIupper_right = (tmp * m_cachedInertiaTopLeft + m_cachedInertiaLowerLeft).inverse(); tmp = invIupper_right * m_cachedInertiaLowerRight; btMatrix3x3 invI_upper_left = (tmp * Binv); btMatrix3x3 invI_lower_right = (invI_upper_left).transpose(); tmp = m_cachedInertiaTopLeft * invI_upper_left; tmp[0][0] -= 1.0; tmp[1][1] -= 1.0; tmp[2][2] -= 1.0; btMatrix3x3 invI_lower_left = (Binv * tmp); //multiply result = invI * rhs { btVector3 vtop = invI_upper_left * rhs.getLinear(); btVector3 tmp; tmp = invIupper_right * rhs.getAngular(); vtop += tmp; btVector3 vbot = invI_lower_left * rhs.getLinear(); tmp = invI_lower_right * rhs.getAngular(); vbot += tmp; result.setVector(vtop, vbot); } } } void btMultiBody::mulMatrix(btScalar *pA, btScalar *pB, int rowsA, int colsA, int rowsB, int colsB, btScalar *pC) const { for (int row = 0; row < rowsA; row++) { for (int col = 0; col < colsB; col++) { pC[row * colsB + col] = 0.f; for (int inner = 0; inner < rowsB; inner++) { pC[row * colsB + col] += pA[row * colsA + inner] * pB[col + inner * colsB]; } } } } void btMultiBody::calcAccelerationDeltasMultiDof(const btScalar *force, btScalar *output, btAlignedObjectArray<btScalar> &scratch_r, btAlignedObjectArray<btVector3> &scratch_v) const { // Temporary matrices/vectors -- use scratch space from caller // so that we don't have to keep reallocating every frame int num_links = getNumLinks(); scratch_r.resize(m_dofCount); scratch_v.resize(4 * num_links + 4); btScalar *r_ptr = m_dofCount ? &scratch_r[0] : 0; btVector3 *v_ptr = &scratch_v[0]; // zhat_i^A (scratch space) btSpatialForceVector *zeroAccSpatFrc = (btSpatialForceVector *)v_ptr; v_ptr += num_links * 2 + 2; // rot_from_parent (cached from calcAccelerations) const btMatrix3x3 *rot_from_parent = &m_matrixBuf[0]; // hhat (cached), accel (scratch) // hhat is NOT stored for the base (but ahat is) const btSpatialForceVector *h = (btSpatialForceVector *)(m_dofCount > 0 ? &m_vectorBuf[0] : 0); btSpatialMotionVector *spatAcc = (btSpatialMotionVector *)v_ptr; v_ptr += num_links * 2 + 2; // Y_i (scratch), invD_i (cached) const btScalar *invD = m_dofCount > 0 ? &m_realBuf[6 + m_dofCount] : 0; btScalar *Y = r_ptr; //////////////// //aux variables btScalar invD_times_Y[6]; //D^{-1} * Y [dofxdof x dofx1 = dofx1] <=> D^{-1} * u; better moved to buffers since it is recalced in calcAccelerationDeltasMultiDof; num_dof of btScalar would cover all bodies btSpatialMotionVector result; //holds results of the SolveImatrix op; it is a spatial motion vector (accel) btScalar Y_minus_hT_a[6]; //Y - h^{T} * a; it's dofx1 for each body so a single 6x1 temp is enough btSpatialForceVector spatForceVecTemps[6]; //6 temporary spatial force vectors btSpatialTransformationMatrix fromParent; ///////////////// // First 'upward' loop. // Combines CompTreeLinkVelocities and InitTreeLinks from Mirtich. // Fill in zero_acc // -- set to force/torque on the base, zero otherwise if (m_fixedBase) { zeroAccSpatFrc[0].setZero(); } else { //test forces fromParent.m_rotMat = rot_from_parent[0]; fromParent.transformRotationOnly(btSpatialForceVector(-force[0], -force[1], -force[2], -force[3], -force[4], -force[5]), zeroAccSpatFrc[0]); } for (int i = 0; i < num_links; ++i) { zeroAccSpatFrc[i + 1].setZero(); } // 'Downward' loop. // (part of TreeForwardDynamics in Mirtich.) for (int i = num_links - 1; i >= 0; --i) { const int parent = m_links[i].m_parent; fromParent.m_rotMat = rot_from_parent[i + 1]; fromParent.m_trnVec = m_links[i].m_cachedRVector; for (int dof = 0; dof < m_links[i].m_dofCount; ++dof) { Y[m_links[i].m_dofOffset + dof] = force[6 + m_links[i].m_dofOffset + dof] - m_links[i].m_axes[dof].dot(zeroAccSpatFrc[i + 1]); } btVector3 in_top, in_bottom, out_top, out_bottom; const btScalar *invDi = &invD[m_links[i].m_dofOffset * m_links[i].m_dofOffset]; for (int dof = 0; dof < m_links[i].m_dofCount; ++dof) { invD_times_Y[dof] = 0.f; for (int dof2 = 0; dof2 < m_links[i].m_dofCount; ++dof2) { invD_times_Y[dof] += invDi[dof * m_links[i].m_dofCount + dof2] * Y[m_links[i].m_dofOffset + dof2]; } } // Zp += pXi * (Zi + hi*Yi/Di) spatForceVecTemps[0] = zeroAccSpatFrc[i + 1]; for (int dof = 0; dof < m_links[i].m_dofCount; ++dof) { const btSpatialForceVector &hDof = h[m_links[i].m_dofOffset + dof]; // spatForceVecTemps[0] += hDof * invD_times_Y[dof]; } fromParent.transformInverse(spatForceVecTemps[0], spatForceVecTemps[1]); zeroAccSpatFrc[parent + 1] += spatForceVecTemps[1]; } // ptr to the joint accel part of the output btScalar *joint_accel = output + 6; // Second 'upward' loop // (part of TreeForwardDynamics in Mirtich) if (m_fixedBase) { spatAcc[0].setZero(); } else { solveImatrix(zeroAccSpatFrc[0], result); spatAcc[0] = -result; } // now do the loop over the m_links for (int i = 0; i < num_links; ++i) { const int parent = m_links[i].m_parent; fromParent.m_rotMat = rot_from_parent[i + 1]; fromParent.m_trnVec = m_links[i].m_cachedRVector; fromParent.transform(spatAcc[parent + 1], spatAcc[i + 1]); for (int dof = 0; dof < m_links[i].m_dofCount; ++dof) { const btSpatialForceVector &hDof = h[m_links[i].m_dofOffset + dof]; // Y_minus_hT_a[dof] = Y[m_links[i].m_dofOffset + dof] - spatAcc[i + 1].dot(hDof); } const btScalar *invDi = &invD[m_links[i].m_dofOffset * m_links[i].m_dofOffset]; mulMatrix(const_cast<btScalar *>(invDi), Y_minus_hT_a, m_links[i].m_dofCount, m_links[i].m_dofCount, m_links[i].m_dofCount, 1, &joint_accel[m_links[i].m_dofOffset]); for (int dof = 0; dof < m_links[i].m_dofCount; ++dof) spatAcc[i + 1] += m_links[i].m_axes[dof] * joint_accel[m_links[i].m_dofOffset + dof]; } // transform base accelerations back to the world frame. btVector3 omegadot_out; omegadot_out = rot_from_parent[0].transpose() * spatAcc[0].getAngular(); output[0] = omegadot_out[0]; output[1] = omegadot_out[1]; output[2] = omegadot_out[2]; btVector3 vdot_out; vdot_out = rot_from_parent[0].transpose() * spatAcc[0].getLinear(); output[3] = vdot_out[0]; output[4] = vdot_out[1]; output[5] = vdot_out[2]; ///////////////// //printf("delta = ["); //for(int dof = 0; dof < getNumDofs() + 6; ++dof) // printf("%.2f ", output[dof]); //printf("]\n"); ///////////////// } void btMultiBody::stepPositionsMultiDof(btScalar dt, btScalar *pq, btScalar *pqd) { int num_links = getNumLinks(); // step position by adding dt * velocity //btVector3 v = getBaseVel(); //m_basePos += dt * v; // btScalar *pBasePos = (pq ? &pq[4] : m_basePos); btScalar *pBaseVel = (pqd ? &pqd[3] : &m_realBuf[3]); //note: the !pqd case assumes m_realBuf holds with base velocity at 3,4,5 (should be wrapped for safety) // pBasePos[0] += dt * pBaseVel[0]; pBasePos[1] += dt * pBaseVel[1]; pBasePos[2] += dt * pBaseVel[2]; /////////////////////////////// //local functor for quaternion integration (to avoid error prone redundancy) struct { //"exponential map" based on btTransformUtil::integrateTransform(..) void operator()(const btVector3 &omega, btQuaternion &quat, bool baseBody, btScalar dt) { //baseBody => quat is alias and omega is global coor //!baseBody => quat is alibi and omega is local coor btVector3 axis; btVector3 angvel; if (!baseBody) { angvel = quatRotate(quat, omega); //if quat is not m_baseQuat, it is alibi => ok } else angvel = omega; btScalar fAngle = angvel.length(); //limit the angular motion if (fAngle * dt > ANGULAR_MOTION_THRESHOLD) { fAngle = btScalar(0.5) * SIMD_HALF_PI / dt; } if (fAngle < btScalar(0.001)) { // use Taylor's expansions of sync function axis = angvel * (btScalar(0.5) * dt - (dt * dt * dt) * (btScalar(0.020833333333)) * fAngle * fAngle); } else { // sync(fAngle) = sin(c*fAngle)/t axis = angvel * (btSin(btScalar(0.5) * fAngle * dt) / fAngle); } if (!baseBody) quat = btQuaternion(axis.x(), axis.y(), axis.z(), btCos(fAngle * dt * btScalar(0.5))) * quat; else quat = quat * btQuaternion(-axis.x(), -axis.y(), -axis.z(), btCos(fAngle * dt * btScalar(0.5))); //equivalent to: quat = (btQuaternion(axis.x(),axis.y(),axis.z(),btCos( fAngle*dt*btScalar(0.5) )) * quat.inverse()).inverse(); quat.normalize(); } } pQuatUpdateFun; /////////////////////////////// //pQuatUpdateFun(getBaseOmega(), m_baseQuat, true, dt); // btScalar *pBaseQuat = pq ? pq : m_baseQuat; btScalar *pBaseOmega = pqd ? pqd : &m_realBuf[0]; //note: the !pqd case assumes m_realBuf starts with base omega (should be wrapped for safety) // btQuaternion baseQuat; baseQuat.setValue(pBaseQuat[0], pBaseQuat[1], pBaseQuat[2], pBaseQuat[3]); btVector3 baseOmega; baseOmega.setValue(pBaseOmega[0], pBaseOmega[1], pBaseOmega[2]); pQuatUpdateFun(baseOmega, baseQuat, true, dt); pBaseQuat[0] = baseQuat.x(); pBaseQuat[1] = baseQuat.y(); pBaseQuat[2] = baseQuat.z(); pBaseQuat[3] = baseQuat.w(); //printf("pBaseOmega = %.4f %.4f %.4f\n", pBaseOmega->x(), pBaseOmega->y(), pBaseOmega->z()); //printf("pBaseVel = %.4f %.4f %.4f\n", pBaseVel->x(), pBaseVel->y(), pBaseVel->z()); //printf("baseQuat = %.4f %.4f %.4f %.4f\n", pBaseQuat->x(), pBaseQuat->y(), pBaseQuat->z(), pBaseQuat->w()); if (pq) pq += 7; if (pqd) pqd += 6; // Finally we can update m_jointPos for each of the m_links for (int i = 0; i < num_links; ++i) { btScalar *pJointPos = (pq ? pq : &m_links[i].m_jointPos[0]); btScalar *pJointVel = (pqd ? pqd : getJointVelMultiDof(i)); switch (m_links[i].m_jointType) { case btMultibodyLink::ePrismatic: case btMultibodyLink::eRevolute: { btScalar jointVel = pJointVel[0]; pJointPos[0] += dt * jointVel; break; } case btMultibodyLink::eSpherical: { btVector3 jointVel; jointVel.setValue(pJointVel[0], pJointVel[1], pJointVel[2]); btQuaternion jointOri; jointOri.setValue(pJointPos[0], pJointPos[1], pJointPos[2], pJointPos[3]); pQuatUpdateFun(jointVel, jointOri, false, dt); pJointPos[0] = jointOri.x(); pJointPos[1] = jointOri.y(); pJointPos[2] = jointOri.z(); pJointPos[3] = jointOri.w(); break; } case btMultibodyLink::ePlanar: { pJointPos[0] += dt * getJointVelMultiDof(i)[0]; btVector3 q0_coors_qd1qd2 = getJointVelMultiDof(i)[1] * m_links[i].getAxisBottom(1) + getJointVelMultiDof(i)[2] * m_links[i].getAxisBottom(2); btVector3 no_q0_coors_qd1qd2 = quatRotate(btQuaternion(m_links[i].getAxisTop(0), pJointPos[0]), q0_coors_qd1qd2); pJointPos[1] += m_links[i].getAxisBottom(1).dot(no_q0_coors_qd1qd2) * dt; pJointPos[2] += m_links[i].getAxisBottom(2).dot(no_q0_coors_qd1qd2) * dt; break; } default: { } } m_links[i].updateCacheMultiDof(pq); if (pq) pq += m_links[i].m_posVarCount; if (pqd) pqd += m_links[i].m_dofCount; } } void btMultiBody::fillConstraintJacobianMultiDof(int link, const btVector3 &contact_point, const btVector3 &normal_ang, const btVector3 &normal_lin, btScalar *jac, btAlignedObjectArray<btScalar> &scratch_r1, btAlignedObjectArray<btVector3> &scratch_v, btAlignedObjectArray<btMatrix3x3> &scratch_m) const { // temporary space int num_links = getNumLinks(); int m_dofCount = getNumDofs(); scratch_v.resize(3 * num_links + 3); //(num_links + base) offsets + (num_links + base) normals_lin + (num_links + base) normals_ang scratch_m.resize(num_links + 1); btVector3 *v_ptr = &scratch_v[0]; btVector3 *p_minus_com_local = v_ptr; v_ptr += num_links + 1; btVector3 *n_local_lin = v_ptr; v_ptr += num_links + 1; btVector3 *n_local_ang = v_ptr; v_ptr += num_links + 1; btAssert(v_ptr - &scratch_v[0] == scratch_v.size()); //scratch_r.resize(m_dofCount); //btScalar *results = m_dofCount > 0 ? &scratch_r[0] : 0; scratch_r1.resize(m_dofCount+num_links); btScalar * results = m_dofCount > 0 ? &scratch_r1[0] : 0; btScalar* links = num_links? &scratch_r1[m_dofCount] : 0; int numLinksChildToRoot=0; int l = link; while (l != -1) { links[numLinksChildToRoot++]=l; l = m_links[l].m_parent; } btMatrix3x3 *rot_from_world = &scratch_m[0]; const btVector3 p_minus_com_world = contact_point - m_basePos; const btVector3 &normal_lin_world = normal_lin; //convenience const btVector3 &normal_ang_world = normal_ang; rot_from_world[0] = btMatrix3x3(m_baseQuat); // omega coeffients first. btVector3 omega_coeffs_world; omega_coeffs_world = p_minus_com_world.cross(normal_lin_world); jac[0] = omega_coeffs_world[0] + normal_ang_world[0]; jac[1] = omega_coeffs_world[1] + normal_ang_world[1]; jac[2] = omega_coeffs_world[2] + normal_ang_world[2]; // then v coefficients jac[3] = normal_lin_world[0]; jac[4] = normal_lin_world[1]; jac[5] = normal_lin_world[2]; //create link-local versions of p_minus_com and normal p_minus_com_local[0] = rot_from_world[0] * p_minus_com_world; n_local_lin[0] = rot_from_world[0] * normal_lin_world; n_local_ang[0] = rot_from_world[0] * normal_ang_world; // Set remaining jac values to zero for now. for (int i = 6; i < 6 + m_dofCount; ++i) { jac[i] = 0; } // Qdot coefficients, if necessary. if (num_links > 0 && link > -1) { // TODO: (Also, we are making 3 separate calls to this function, for the normal & the 2 friction directions, // which is resulting in repeated work being done...) // calculate required normals & positions in the local frames. for (int a = 0; a < numLinksChildToRoot; a++) { int i = links[numLinksChildToRoot-1-a]; // transform to local frame const int parent = m_links[i].m_parent; const btMatrix3x3 mtx(m_links[i].m_cachedRotParentToThis); rot_from_world[i + 1] = mtx * rot_from_world[parent + 1]; n_local_lin[i + 1] = mtx * n_local_lin[parent + 1]; n_local_ang[i + 1] = mtx * n_local_ang[parent + 1]; p_minus_com_local[i + 1] = mtx * p_minus_com_local[parent + 1] - m_links[i].m_cachedRVector; // calculate the jacobian entry switch (m_links[i].m_jointType) { case btMultibodyLink::eRevolute: { results[m_links[i].m_dofOffset] = n_local_lin[i + 1].dot(m_links[i].getAxisTop(0).cross(p_minus_com_local[i + 1]) + m_links[i].getAxisBottom(0)); results[m_links[i].m_dofOffset] += n_local_ang[i + 1].dot(m_links[i].getAxisTop(0)); break; } case btMultibodyLink::ePrismatic: { results[m_links[i].m_dofOffset] = n_local_lin[i + 1].dot(m_links[i].getAxisBottom(0)); break; } case btMultibodyLink::eSpherical: { results[m_links[i].m_dofOffset + 0] = n_local_lin[i + 1].dot(m_links[i].getAxisTop(0).cross(p_minus_com_local[i + 1]) + m_links[i].getAxisBottom(0)); results[m_links[i].m_dofOffset + 1] = n_local_lin[i + 1].dot(m_links[i].getAxisTop(1).cross(p_minus_com_local[i + 1]) + m_links[i].getAxisBottom(1)); results[m_links[i].m_dofOffset + 2] = n_local_lin[i + 1].dot(m_links[i].getAxisTop(2).cross(p_minus_com_local[i + 1]) + m_links[i].getAxisBottom(2)); results[m_links[i].m_dofOffset + 0] += n_local_ang[i + 1].dot(m_links[i].getAxisTop(0)); results[m_links[i].m_dofOffset + 1] += n_local_ang[i + 1].dot(m_links[i].getAxisTop(1)); results[m_links[i].m_dofOffset + 2] += n_local_ang[i + 1].dot(m_links[i].getAxisTop(2)); break; } case btMultibodyLink::ePlanar: { results[m_links[i].m_dofOffset + 0] = n_local_lin[i + 1].dot(m_links[i].getAxisTop(0).cross(p_minus_com_local[i + 1])); // + m_links[i].getAxisBottom(0)); results[m_links[i].m_dofOffset + 1] = n_local_lin[i + 1].dot(m_links[i].getAxisBottom(1)); results[m_links[i].m_dofOffset + 2] = n_local_lin[i + 1].dot(m_links[i].getAxisBottom(2)); break; } default: { } } } // Now copy through to output. //printf("jac[%d] = ", link); while (link != -1) { for (int dof = 0; dof < m_links[link].m_dofCount; ++dof) { jac[6 + m_links[link].m_dofOffset + dof] = results[m_links[link].m_dofOffset + dof]; //printf("%.2f\t", jac[6 + m_links[link].m_dofOffset + dof]); } link = m_links[link].m_parent; } //printf("]\n"); } } void btMultiBody::wakeUp() { m_sleepTimer = 0; m_awake = true; } void btMultiBody::goToSleep() { m_awake = false; } void btMultiBody::checkMotionAndSleepIfRequired(btScalar timestep) { extern bool gDisableDeactivation; if (!m_canSleep || gDisableDeactivation) { m_awake = true; m_sleepTimer = 0; return; } // motion is computed as omega^2 + v^2 + (sum of squares of joint velocities) btScalar motion = 0; { for (int i = 0; i < 6 + m_dofCount; ++i) motion += m_realBuf[i] * m_realBuf[i]; } if (motion < SLEEP_EPSILON) { m_sleepTimer += timestep; if (m_sleepTimer > SLEEP_TIMEOUT) { goToSleep(); } } else { m_sleepTimer = 0; if (m_canWakeup) { if (!m_awake) wakeUp(); } } } void btMultiBody::forwardKinematics(btAlignedObjectArray<btQuaternion> &world_to_local, btAlignedObjectArray<btVector3> &local_origin) { int num_links = getNumLinks(); // Cached 3x3 rotation matrices from parent frame to this frame. btMatrix3x3 *rot_from_parent = (btMatrix3x3 *)&m_matrixBuf[0]; rot_from_parent[0] = btMatrix3x3(m_baseQuat); //m_baseQuat assumed to be alias!? for (int i = 0; i < num_links; ++i) { rot_from_parent[i + 1] = btMatrix3x3(m_links[i].m_cachedRotParentToThis); } int nLinks = getNumLinks(); ///base + num m_links world_to_local.resize(nLinks + 1); local_origin.resize(nLinks + 1); world_to_local[0] = getWorldToBaseRot(); local_origin[0] = getBasePos(); for (int k = 0; k < getNumLinks(); k++) { const int parent = getParent(k); world_to_local[k + 1] = getParentToLocalRot(k) * world_to_local[parent + 1]; local_origin[k + 1] = local_origin[parent + 1] + (quatRotate(world_to_local[k + 1].inverse(), getRVector(k))); } for (int link = 0; link < getNumLinks(); link++) { int index = link + 1; btVector3 posr = local_origin[index]; btScalar quat[4] = {-world_to_local[index].x(), -world_to_local[index].y(), -world_to_local[index].z(), world_to_local[index].w()}; btTransform tr; tr.setIdentity(); tr.setOrigin(posr); tr.setRotation(btQuaternion(quat[0], quat[1], quat[2], quat[3])); getLink(link).m_cachedWorldTransform = tr; } } void btMultiBody::updateCollisionObjectWorldTransforms(btAlignedObjectArray<btQuaternion> &world_to_local, btAlignedObjectArray<btVector3> &local_origin) { world_to_local.resize(getNumLinks() + 1); local_origin.resize(getNumLinks() + 1); world_to_local[0] = getWorldToBaseRot(); local_origin[0] = getBasePos(); if (getBaseCollider()) { btVector3 posr = local_origin[0]; // float pos[4]={posr.x(),posr.y(),posr.z(),1}; btScalar quat[4] = {-world_to_local[0].x(), -world_to_local[0].y(), -world_to_local[0].z(), world_to_local[0].w()}; btTransform tr; tr.setIdentity(); tr.setOrigin(posr); tr.setRotation(btQuaternion(quat[0], quat[1], quat[2], quat[3])); getBaseCollider()->setWorldTransform(tr); } for (int k = 0; k < getNumLinks(); k++) { const int parent = getParent(k); world_to_local[k + 1] = getParentToLocalRot(k) * world_to_local[parent + 1]; local_origin[k + 1] = local_origin[parent + 1] + (quatRotate(world_to_local[k + 1].inverse(), getRVector(k))); } for (int m = 0; m < getNumLinks(); m++) { btMultiBodyLinkCollider *col = getLink(m).m_collider; if (col) { int link = col->m_link; btAssert(link == m); int index = link + 1; btVector3 posr = local_origin[index]; // float pos[4]={posr.x(),posr.y(),posr.z(),1}; btScalar quat[4] = {-world_to_local[index].x(), -world_to_local[index].y(), -world_to_local[index].z(), world_to_local[index].w()}; btTransform tr; tr.setIdentity(); tr.setOrigin(posr); tr.setRotation(btQuaternion(quat[0], quat[1], quat[2], quat[3])); col->setWorldTransform(tr); } } } int btMultiBody::calculateSerializeBufferSize() const { int sz = sizeof(btMultiBodyData); return sz; } ///fills the dataBuffer and returns the struct name (and 0 on failure) const char *btMultiBody::serialize(void *dataBuffer, class btSerializer *serializer) const { btMultiBodyData *mbd = (btMultiBodyData *)dataBuffer; getBasePos().serialize(mbd->m_baseWorldPosition); getWorldToBaseRot().inverse().serialize(mbd->m_baseWorldOrientation); getBaseVel().serialize(mbd->m_baseLinearVelocity); getBaseOmega().serialize(mbd->m_baseAngularVelocity); mbd->m_baseMass = this->getBaseMass(); getBaseInertia().serialize(mbd->m_baseInertia); { char *name = (char *)serializer->findNameForPointer(m_baseName); mbd->m_baseName = (char *)serializer->getUniquePointer(name); if (mbd->m_baseName) { serializer->serializeName(name); } } mbd->m_numLinks = this->getNumLinks(); if (mbd->m_numLinks) { int sz = sizeof(btMultiBodyLinkData); int numElem = mbd->m_numLinks; btChunk *chunk = serializer->allocate(sz, numElem); btMultiBodyLinkData *memPtr = (btMultiBodyLinkData *)chunk->m_oldPtr; for (int i = 0; i < numElem; i++, memPtr++) { memPtr->m_jointType = getLink(i).m_jointType; memPtr->m_dofCount = getLink(i).m_dofCount; memPtr->m_posVarCount = getLink(i).m_posVarCount; getLink(i).m_inertiaLocal.serialize(memPtr->m_linkInertia); getLink(i).m_absFrameTotVelocity.m_topVec.serialize(memPtr->m_absFrameTotVelocityTop); getLink(i).m_absFrameTotVelocity.m_bottomVec.serialize(memPtr->m_absFrameTotVelocityBottom); getLink(i).m_absFrameLocVelocity.m_topVec.serialize(memPtr->m_absFrameLocVelocityTop); getLink(i).m_absFrameLocVelocity.m_bottomVec.serialize(memPtr->m_absFrameLocVelocityBottom); memPtr->m_linkMass = getLink(i).m_mass; memPtr->m_parentIndex = getLink(i).m_parent; memPtr->m_jointDamping = getLink(i).m_jointDamping; memPtr->m_jointFriction = getLink(i).m_jointFriction; memPtr->m_jointLowerLimit = getLink(i).m_jointLowerLimit; memPtr->m_jointUpperLimit = getLink(i).m_jointUpperLimit; memPtr->m_jointMaxForce = getLink(i).m_jointMaxForce; memPtr->m_jointMaxVelocity = getLink(i).m_jointMaxVelocity; getLink(i).m_eVector.serialize(memPtr->m_parentComToThisPivotOffset); getLink(i).m_dVector.serialize(memPtr->m_thisPivotToThisComOffset); getLink(i).m_zeroRotParentToThis.serialize(memPtr->m_zeroRotParentToThis); btAssert(memPtr->m_dofCount <= 3); for (int dof = 0; dof < getLink(i).m_dofCount; dof++) { getLink(i).getAxisBottom(dof).serialize(memPtr->m_jointAxisBottom[dof]); getLink(i).getAxisTop(dof).serialize(memPtr->m_jointAxisTop[dof]); memPtr->m_jointTorque[dof] = getLink(i).m_jointTorque[dof]; memPtr->m_jointVel[dof] = getJointVelMultiDof(i)[dof]; } int numPosVar = getLink(i).m_posVarCount; for (int posvar = 0; posvar < numPosVar; posvar++) { memPtr->m_jointPos[posvar] = getLink(i).m_jointPos[posvar]; } { char *name = (char *)serializer->findNameForPointer(m_links[i].m_linkName); memPtr->m_linkName = (char *)serializer->getUniquePointer(name); if (memPtr->m_linkName) { serializer->serializeName(name); } } { char *name = (char *)serializer->findNameForPointer(m_links[i].m_jointName); memPtr->m_jointName = (char *)serializer->getUniquePointer(name); if (memPtr->m_jointName) { serializer->serializeName(name); } } memPtr->m_linkCollider = (btCollisionObjectData *)serializer->getUniquePointer(getLink(i).m_collider); } serializer->finalizeChunk(chunk, btMultiBodyLinkDataName, BT_ARRAY_CODE, (void *)&m_links[0]); } mbd->m_links = mbd->m_numLinks ? (btMultiBodyLinkData *)serializer->getUniquePointer((void *)&m_links[0]) : 0; // Fill padding with zeros to appease msan. #ifdef BT_USE_DOUBLE_PRECISION memset(mbd->m_padding, 0, sizeof(mbd->m_padding)); #endif return btMultiBodyDataName; }
.size 8000 .data@0 01 .text@48 jp ff81 .data@9c 02 03 04 05 .text@100 jp lbegin .data@143 c0 .text@150 lbegin: ld hl, ff81 ld a, 0e ld(hl++), a ld a, 27 ld(hl++), a ld a, 3e ld(hl++), a ld a, 00 ld(hl++), a ld a, e0 ld(hl++), a ld a, 46 ld(hl++), a ld a, 0d ld(hl++), a ld a, 20 ld(hl++), a ld a, fd ld(hl++), a xor a, a ld(hl++), a ld(hl++), a ld(hl++), a ld a, fa ld(hl++), a ld a, 00 ld(hl++), a ld a, 00 ld(hl++), a ld a, 06 ld(hl++), a inc a ld(hl++), a ld a, 00 ld(hl++), a ld a, e0 ld(hl++), a ld a, 80 ld(hl++), a ld a, 0e ld(hl++), a ld a, 28 ld(hl++), a ld a, 0d ld(hl++), a ld a, 20 ld(hl++), a ld a, fd ld(hl++), a ld a, c3 ld(hl++), a xor a, a ld(hl++), a ld a, 70 ld(hl++), a ld b, 90 call lwaitly_b ld hl, fe00 ld c, a0 ld a, 06 lbegin_fill_oam: ld(hl++), a dec c jrnz lbegin_fill_oam ld a, 90 ldff(45), a ld a, 40 ldff(41), a xor a, a ldff(0f), a ld a, 02 ldff(ff), a ei nop halt .text@7000 lprint_ff80: ld b, 91 call lwaitly_b xor a, a ldff(40), a ld bc, 7a00 ld hl, 8000 ld d, a0 lprint_copytiles: ld a, (bc) inc bc ld(hl++), a dec d jrnz lprint_copytiles ldff a, (80) ld(9800), a ld a, c0 ldff(47), a ld a, 80 ldff(68), a ld a, ff ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a xor a, a ldff(69), a ldff(69), a ldff(43), a ld a, 91 ldff(40), a lprint_limbo: jr lprint_limbo .text@7400 lwaitly_b: ld c, 44 lwaitly_b_loop: ldff a, (c) cmp a, b jrnz lwaitly_b_loop ret .data@7a00 00 00 7f 7f 41 41 41 41 41 41 41 41 41 41 7f 7f 00 00 08 08 08 08 08 08 08 08 08 08 08 08 08 08 00 00 7f 7f 01 01 01 01 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 01 01 01 01 3f 3f 01 01 01 01 7f 7f 00 00 41 41 41 41 41 41 7f 7f 01 01 01 01 01 01 00 00 7f 7f 40 40 40 40 7e 7e 01 01 01 01 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 41 41 41 41 7f 7f 00 00 7f 7f 01 01 02 02 04 04 08 08 10 10 10 10 00 00 3e 3e 41 41 41 41 3e 3e 41 41 41 41 3e 3e 00 00 7f 7f 41 41 41 41 7f 7f 01 01 01 01 7f 7f
; A061776: Start with a single triangle; at n-th generation add a triangle at each vertex, allowing triangles to overlap; sequence gives number of triangles in n-th generation. ; 1,3,6,12,18,30,42,66,90,138,186,282,378,570,762,1146,1530,2298,3066,4602,6138,9210,12282,18426,24570,36858,49146,73722,98298,147450,196602,294906,393210,589818,786426,1179642,1572858,2359290,3145722,4718586,6291450,9437178,12582906,18874362,25165818,37748730,50331642,75497466,100663290,150994938,201326586,301989882,402653178,603979770,805306362,1207959546,1610612730,2415919098,3221225466,4831838202,6442450938,9663676410,12884901882,19327352826,25769803770,38654705658,51539607546,77309411322,103079215098,154618822650,206158430202,309237645306,412316860410,618475290618,824633720826,1236950581242,1649267441658,2473901162490,3298534883322,4947802324986,6597069766650,9895604649978,13194139533306,19791209299962,26388279066618,39582418599930,52776558133242,79164837199866,105553116266490,158329674399738,211106232532986,316659348799482,422212465065978,633318697598970,844424930131962,1266637395197946,1688849860263930,2533274790395898,3377699720527866,5066549580791802,6755399441055738 mov $2,1 lpb $0,1 add $1,1 trn $2,$0 sub $0,1 add $2,$1 mov $1,$2 lpe add $2,$1 add $1,$2
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1992 -- All Rights Reserved PROJECT: dBase IV MODULE: Lib FILE: libFormat.asm AUTHOR: Ted H. Kim, 9/14/92 REVISION HISTORY: Name Date Description ---- ---- ----------- ted 9/92 Initial revision DESCRIPTION: This file contains the library definition of dBase IV. $Id: libFormat.asm,v 1.1 97/04/07 11:43:42 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DefTransLib DefTransFormat TF_DBASE_FOUR, \ "dBase IV", \ "*.DBF", \ ImportOptionsGroup, \ ExportOptionsGroup, \ <mask IFI_IMPORT_CAPABLE or \ mask IFI_EXPORT_CAPABLE> EndTransLib <mask IDC_SPREADSHEET> idata segment ImpexMappingControlClass idata ends
; ; Copyright (C) 2021 by Intel Corporation ; ; Permission to use, copy, modify, and/or distribute this software for any ; purpose with or without fee is hereby granted. ; ; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH ; REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY ; AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, ; INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM ; LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR ; OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR ; PERFORMANCE OF THIS SOFTWARE. ; ; .globl scalar_histogram ; void scalar_histogram(const int32_t *input, uint32_t *output, uint64_t num_inputs, uint64_t bins); ; ; On entry: ; rcx = input ; rdx = ouptut ; r8 = num_inputs ; r9 = bins .code scalar_histogram PROC public push rbx mov r10d, r9d ; mov r10d, bins_minus_1 dec r10d ; mov r8, num_inputs shr r8d, 1 ; mov rcx, pInput mov r11, rdx ; mov r11, pHistogram xor rax, rax histogram_loop: lea r9d, [rax + rax] inc eax movsxd r9, r9d mov edx, [rcx+r9*4] and edx, r10d mov ebx, [rcx+r9*4+4] movsxd rdx, edx and ebx, r10d movsxd rbx, ebx inc dword ptr [r11+rdx*4] inc dword ptr [r11+rbx*4] cmp eax, r8d jb histogram_loop pop rbx ret scalar_histogram ENDP end
/* ************************************************************************ * Copyright 2018-2020 Advanced Micro Devices, Inc. * ************************************************************************ */ #include "cblas_interface.hpp" #include "flops.hpp" #include "norm.hpp" #include "rocblas.hpp" #include "rocblas_init.hpp" #include "rocblas_math.hpp" #include "rocblas_random.hpp" #include "rocblas_test.hpp" #include "rocblas_vector.hpp" #include "unit.hpp" #include "utility.hpp" template <typename T> void testing_set_get_vector(const Arguments& arg) { rocblas_int M = arg.M; rocblas_int incx = arg.incx; rocblas_int incy = arg.incy; rocblas_int incb = arg.incb; rocblas_local_handle handle; // argument sanity check, quick return if input parameters are invalid before allocating invalid // memory if(M < 0 || incx <= 0 || incy <= 0 || incb <= 0) { static const size_t safe_size = 100; host_vector<T> hx(safe_size); host_vector<T> hy(safe_size); device_vector<T> db(safe_size); CHECK_DEVICE_ALLOCATION(db.memcheck()); EXPECT_ROCBLAS_STATUS(rocblas_set_vector(M, sizeof(T), hx, incx, db, incb), rocblas_status_invalid_size); EXPECT_ROCBLAS_STATUS(rocblas_get_vector(M, sizeof(T), db, incb, hy, incy), rocblas_status_invalid_size); return; } // Naming: dK is in GPU (device) memory. hK is in CPU (host) memory host_vector<T> hx(M * size_t(incx)); host_vector<T> hy(M * size_t(incy)); host_vector<T> hb(M * size_t(incb)); host_vector<T> hy_gold(M * size_t(incy)); double gpu_time_used, cpu_time_used; double rocblas_bandwidth, cpu_bandwidth; double rocblas_error = 0.0; // allocate memory on device device_vector<T> db(M * size_t(incb)); CHECK_DEVICE_ALLOCATION(db.memcheck()); // Initial Data on CPU rocblas_seedrand(); rocblas_init<T>(hx, 1, M, incx); rocblas_init<T>(hy, 1, M, incy); rocblas_init<T>(hb, 1, M, incb); hy_gold = hy; if(arg.unit_check || arg.norm_check) { // GPU BLAS rocblas_init<T>(hy, 1, M, incy); rocblas_init<T>(hb, 1, M, incb); CHECK_HIP_ERROR(hipMemcpy(db, hb, sizeof(T) * incb * M, hipMemcpyHostToDevice)); CHECK_ROCBLAS_ERROR(rocblas_set_vector(M, sizeof(T), hx, incx, db, incb)); CHECK_ROCBLAS_ERROR(rocblas_get_vector(M, sizeof(T), db, incb, hy, incy)); cpu_time_used = get_time_us(); // reference calculation for(int i = 0; i < M; i++) { hy_gold[i * incy] = hx[i * incx]; } cpu_time_used = get_time_us() - cpu_time_used; cpu_bandwidth = (M * sizeof(T)) / cpu_time_used / 1e3; if(arg.unit_check) { unit_check_general<T>(1, M, incy, hy, hy_gold); } if(arg.norm_check) { rocblas_error = norm_check_general<T>('F', 1, M, incy, hy, hy_gold); } } if(arg.timing) { int number_timing_iterations = arg.iters; gpu_time_used = get_time_us(); // in microseconds for(int iter = 0; iter < number_timing_iterations; iter++) { rocblas_set_vector(M, sizeof(T), hx, incx, db, incb); rocblas_get_vector(M, sizeof(T), db, incb, hy, incy); } gpu_time_used = get_time_us() - gpu_time_used; rocblas_bandwidth = (M * sizeof(T)) / gpu_time_used / 1e3 / number_timing_iterations; std::cout << "M,incx,incy,incb,rocblas-GB/s"; if(arg.norm_check && cpu_bandwidth != std::numeric_limits<T>::infinity()) std::cout << ",CPU-GB/s"; std::cout << std::endl; std::cout << M << "," << incx << "," << incy << "," << incb << "," << rocblas_bandwidth; if(arg.norm_check && cpu_bandwidth != std::numeric_limits<T>::infinity()) std::cout << "," << cpu_bandwidth; std::cout << std::endl; } }
#define __FAAS_USED_IN_BINDING #include "ipc/shm_region.h" #include "ipc/base.h" #include "common/stat.h" #include "common/time.h" #include "utils/fs.h" #include <sys/mman.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> namespace faas { namespace ipc { std::unique_ptr<ShmRegion> ShmCreate(std::string_view name, size_t size) { std::string full_path = fs_utils::JoinPath(GetRootPathForShm(), name); int fd = open(full_path.c_str(), O_CREAT|O_EXCL|O_RDWR, __FAAS_FILE_CREAT_MODE); if (fd == -1) { PLOG(ERROR) << "open " << full_path << " failed"; return nullptr; } PCHECK(ftruncate(fd, static_cast<long>(size)) == 0) << "ftruncate failed"; void* ptr = nullptr; if (size > 0) { ptr = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); PCHECK(ptr != MAP_FAILED) << "mmap failed"; memset(ptr, 0, size); } PCHECK(close(fd) == 0) << "close failed"; return std::unique_ptr<ShmRegion>(new ShmRegion(name, reinterpret_cast<char*>(ptr), size)); } std::unique_ptr<ShmRegion> ShmOpen(std::string_view name, bool readonly) { std::string full_path = fs_utils::JoinPath(GetRootPathForShm(), name); int fd = open(full_path.c_str(), readonly ? O_RDONLY : O_RDWR); if (fd == -1) { PLOG(ERROR) << "open " << full_path << " failed"; return nullptr; } struct stat statbuf; PCHECK(fstat(fd, &statbuf) == 0) << "fstat failed"; size_t size = gsl::narrow_cast<size_t>(statbuf.st_size); void* ptr = nullptr; if (size > 0) { ptr = mmap(0, size, readonly ? PROT_READ : (PROT_READ|PROT_WRITE), MAP_SHARED, fd, 0); PCHECK(ptr != MAP_FAILED) << "mmap failed"; } PCHECK(close(fd) == 0) << "close failed"; return std::unique_ptr<ShmRegion>(new ShmRegion(name, reinterpret_cast<char*>(ptr), size)); } ShmRegion::~ShmRegion() { if (size_ > 0) { PCHECK(munmap(base_, size_) == 0); } if (remove_on_destruction_) { std::string full_path = fs_utils::JoinPath(GetRootPathForShm(), name_); if (!fs_utils::Remove(full_path)) { PLOG(ERROR) << "Failed to remove " << full_path; } } } } // namespace ipc } // namespace faas
#include "c3.h" #include "chart.h" #include "aui.h" #include "aui_uniqueid.h" #include "aui_ldl.h" #include "aui_window.h" #include "aui_bitmapfont.h" #include "pixelutils.h" #include "primitives.h" #include "c3_hypertipwindow.h" #include "aui_hypertextbox.h" #include "colorset.h" // g_colorSet #include "c3windows.h" #include "ctp2_button.h" #include "ctp2_Static.h" #include "c3ui.h" #include "AdvanceRecord.h" #include "player.h" #include "SelItem.h" #include "Advances.h" #include "prjfile.h" #include "StrDB.h" #include "IconRecord.h" #include "advanceutil.h" #include "ldl_file.hpp" extern C3UI *g_c3ui; extern ProjectFile *g_GreatLibPF; #define k_CHART_PATTERN "chart.tga" Chart::Chart( AUI_ERRCODE *retval, uint32 id, MBCHAR *ldlBlock, ControlActionCallback *ActionFunc, void *cookie ) : aui_ImageBase( ldlBlock ), aui_TextBase( ldlBlock, (MBCHAR *)NULL ), ctp2_Static( retval, id, ldlBlock ) { InitCommon( ldlBlock ); } Chart::Chart( AUI_ERRCODE *retval, uint32 id, sint32 x, sint32 y, sint32 width, sint32 height, MBCHAR *pattern, ControlActionCallback *ActionFunc, void *cookie ) : aui_ImageBase( (sint32)0 ), aui_TextBase( NULL ), ctp2_Static( retval, id, x, y, width, height, pattern, NULL, 0, 0, 0 ) { InitCommon( NULL ); } AUI_ERRCODE Chart::InitCommon( MBCHAR *ldlBlock ) { sint32 i; AUI_ERRCODE errcode; m_centerButton = NULL; m_left = NULL; m_right = NULL; for ( i = 0;i < k_MAX_PREREQ; i++ ) { m_preReqButton[i] = NULL; } for ( i = 0;i < k_MAX_EITHER_PREREQ; i++ ) { m_eitherPreReqButton[i] = NULL; } for ( i = 0;i < k_MAX_LEADS_TO;i++ ) { m_leadsToButton[i] = NULL; } static MBCHAR block[ k_AUI_LDL_MAXBLOCK + 1 ]; if ( ldlBlock ) { sprintf( block, "%s.%s", ldlBlock, k_CHART_LDL_LEFTIMAGE ); if (aui_Ldl::GetLdl()->FindDataBlock(block)) { m_left = new ctp2_Static( &errcode, aui_UniqueId(), block ); } } if ( ldlBlock ) { sprintf( block, "%s.%s", ldlBlock, k_CHART_LDL_RIGHTIMAGE ); if (aui_Ldl::GetLdl()->FindDataBlock( block ) ) { m_right = new ctp2_Static( &errcode, aui_UniqueId(), block ); } } if ( ldlBlock ) { sprintf( block, "%s.%s", ldlBlock, k_CHART_LDL_BUTTON ); if (aui_Ldl::GetLdl()->FindDataBlock( block ) ) { m_centerButton = new ctp2_Button( &errcode, aui_UniqueId(), block, ChartCenterActionCallback, this ); errcode = AddSubControl( m_centerButton ); Assert( errcode == AUI_ERRCODE_OK ); if ( errcode != AUI_ERRCODE_OK ) return AUI_ERRCODE_CONTROLFAILURE; for ( i = 0; i < k_MAX_PREREQ; i++ ) { m_preReqButton[i] = new ctp2_Button( &errcode, aui_UniqueId(), block, ChartPreReqActionCallback, this ); errcode = AddSubControl( m_preReqButton[i] ); Assert( errcode == AUI_ERRCODE_OK ); if ( errcode != AUI_ERRCODE_OK ) return AUI_ERRCODE_CONTROLFAILURE; } for ( i = 0; i < k_MAX_EITHER_PREREQ; i++ ) { m_eitherPreReqButton[i] = new ctp2_Button( &errcode, aui_UniqueId(), block, ChartEitherPreReqActionCallback, this ); errcode = AddSubControl( m_eitherPreReqButton[i] ); Assert( errcode == AUI_ERRCODE_OK ); if ( errcode != AUI_ERRCODE_OK ) return AUI_ERRCODE_CONTROLFAILURE; } for ( i = 0; i < k_MAX_LEADS_TO;i++ ) { m_leadsToButton[i] = new ctp2_Button( &errcode, aui_UniqueId(), block, ChartLeadsToActionCallback, this ); errcode = AddSubControl( m_leadsToButton[i] ); Assert( errcode == AUI_ERRCODE_OK ); if ( errcode != AUI_ERRCODE_OK ) return AUI_ERRCODE_CONTROLFAILURE; } } } if ( !m_centerButton ) { m_centerButton = new ctp2_Button( &errcode, aui_UniqueId(), NULL, k_CHART_PATTERN, 0, 0, 100, 20, ChartCenterActionCallback, this ); errcode = AddSubControl( m_centerButton ); Assert( errcode == AUI_ERRCODE_OK ); if ( errcode != AUI_ERRCODE_OK ) return AUI_ERRCODE_CONTROLFAILURE; aui_BitmapFont * font = m_centerButton->GetTextFont(); Assert(font); font->SetPointSize(14); m_centerButton->TextFlags() = k_AUI_BITMAPFONT_DRAWFLAG_JUSTCENTER; for ( i = 0;i < k_MAX_PREREQ;i++ ) { m_preReqButton[i] = new ctp2_Button( &errcode, aui_UniqueId(), NULL, k_CHART_PATTERN, 0, 0, 100, 20, ChartPreReqActionCallback, this ); errcode = AddSubControl( m_preReqButton[i] ); Assert( errcode == AUI_ERRCODE_OK ); if ( errcode != AUI_ERRCODE_OK ) return AUI_ERRCODE_CONTROLFAILURE; m_preReqButton[i]->Hide(); m_preReqButton[i]->TextFlags() = k_AUI_BITMAPFONT_DRAWFLAG_JUSTCENTER; font = m_preReqButton[i]->GetTextFont(); Assert(font); font->SetPointSize(14); } for ( i = 0;i < k_MAX_EITHER_PREREQ;i++ ) { m_eitherPreReqButton[i] = new ctp2_Button( &errcode, aui_UniqueId(), NULL, k_CHART_PATTERN, 0, 0, 100, 20, ChartEitherPreReqActionCallback, this ); errcode = AddSubControl( m_eitherPreReqButton[i] ); Assert( errcode == AUI_ERRCODE_OK ); if ( errcode != AUI_ERRCODE_OK ) return AUI_ERRCODE_CONTROLFAILURE; m_eitherPreReqButton[i]->Hide(); m_eitherPreReqButton[i]->TextFlags() = k_AUI_BITMAPFONT_DRAWFLAG_JUSTCENTER; font = m_eitherPreReqButton[i]->GetTextFont(); Assert(font); font->SetPointSize(14); } for ( i = 0;i < k_MAX_LEADS_TO;i++ ) { m_leadsToButton[i] = new ctp2_Button( &errcode, aui_UniqueId(), NULL, k_CHART_PATTERN, 0, 0, 100, 20, ChartLeadsToActionCallback, this ); errcode = AddSubControl( m_leadsToButton[i] ); Assert( errcode == AUI_ERRCODE_OK ); if ( errcode != AUI_ERRCODE_OK ) return AUI_ERRCODE_CONTROLFAILURE; m_leadsToButton[i]->Hide(); m_leadsToButton[i]->TextFlags() = k_AUI_BITMAPFONT_DRAWFLAG_JUSTCENTER; font = m_leadsToButton[i]->GetTextFont(); Assert(font); font->SetPointSize(14); } } m_heightBetweenButtons = ( m_height - (m_centerButton->Height() * 4) ) / 5; m_distFromSide = ( (m_width - (m_centerButton->Width() * 3)) / 4 ); m_distFromCenter = m_distFromSide; return AUI_ERRCODE_OK; } Chart::~Chart() { sint32 i; for ( i = 0;i < k_MAX_PREREQ;i++ ) { delete m_preReqButton[i]; } for ( i = 0;i < k_MAX_EITHER_PREREQ;i++ ) { delete m_eitherPreReqButton[i]; } for ( i = 0;i < k_MAX_LEADS_TO;i++ ) { delete m_leadsToButton[i]; } delete m_centerButton; delete m_left; delete m_right; } AUI_ERRCODE Chart::Show() { AUI_ERRCODE errcode = ctp2_Static::Show(); Assert( errcode == AUI_ERRCODE_OK ); if ( errcode != AUI_ERRCODE_OK ) return AUI_ERRCODE_CONTROLFAILURE; int i; for (i = m_numPreReq; i < k_MAX_PREREQ; i++) { m_preReqButton[i]->Hide(); } for (i = m_numEitherPreReq; i < k_MAX_EITHER_PREREQ; i++) { m_eitherPreReqButton[i]->Hide(); } for ( i = m_numLeadsTo;i < k_MAX_LEADS_TO;i++ ) { m_leadsToButton[i]->Hide(); } return AUI_ERRCODE_OK; } AUI_ERRCODE Chart::Draw( aui_Surface *surface, sint32 x, sint32 y ) { AUI_ERRCODE errcode = AUI_ERRCODE_OK; if ( !IsHidden() ) errcode = DrawThis( surface, x, y ); if ( errcode == AUI_ERRCODE_OK ) DrawChildren( surface, x, y ); m_draw = 0; if ( IsHidden() ) return AUI_ERRCODE_OK; if ( !surface ) surface = m_window->TheSurface(); RECT rect = { 0, 0, m_width, m_height }; OffsetRect( &rect, m_x + x, m_y + y ); ToWindow( &rect ); sint32 i; RECT tempRect; for ( i = 0; i < m_numPreReq; i++ ) { tempRect.left = m_preReqButton[i]->X(); tempRect.top = m_preReqButton[i]->Y(); tempRect.right = tempRect.left + m_preReqButton[i]->Width(); tempRect.bottom = tempRect.top + m_preReqButton[i]->Height(); InflateRect( &tempRect, 1, 1 ); OffsetRect( &tempRect, rect.left, rect.top ); primitives_FrameRect16( surface, &tempRect, g_colorSet->GetColor((COLOR)m_preReqColor[i]) ); } for ( i = 0; i < m_numEitherPreReq; i++ ) { tempRect.left = m_eitherPreReqButton[i]->X(); tempRect.top = m_eitherPreReqButton[i]->Y(); tempRect.right = tempRect.left + m_eitherPreReqButton[i]->Width(); tempRect.bottom = tempRect.top + m_eitherPreReqButton[i]->Height(); InflateRect( &tempRect, 1, 1 ); OffsetRect( &tempRect, rect.left, rect.top ); primitives_FrameRect16( surface, &tempRect, g_colorSet->GetColor((COLOR)m_eitherPreReqColor[i]) ); } for ( i = 0; i < m_numLeadsTo; i++ ) { tempRect.left = m_leadsToButton[i]->X(); tempRect.top = m_leadsToButton[i]->Y(); tempRect.right = tempRect.left + m_leadsToButton[i]->Width(); tempRect.bottom = tempRect.top + m_leadsToButton[i]->Height(); InflateRect( &tempRect, 1, 1 ); OffsetRect( &tempRect, rect.left, rect.top ); primitives_FrameRect16( surface, &tempRect, g_colorSet->GetColor((COLOR)m_leadsToColor[i]) ); } tempRect.left = m_centerButton->X(); tempRect.top = m_centerButton->Y(); tempRect.right = tempRect.left + m_centerButton->Width(); tempRect.bottom = tempRect.top + m_centerButton->Height(); InflateRect( &tempRect, 1, 1 ); OffsetRect( &tempRect, rect.left, rect.top ); primitives_FrameRect16( surface, &tempRect, g_colorSet->GetColor((COLOR)m_centerColor) ); POINT center, leftCenter, rightCenter; center.x = rect.left + m_centerButton->X(); center.y = rect.top + m_centerButton->Y() + m_centerButton->Height() / 2; leftCenter.x = center.x - m_distFromCenter / 2; leftCenter.y = center.y; rightCenter.x = center.x + m_centerButton->Width() + m_distFromCenter / 2; rightCenter.y = center.y; if ( m_numPreReq ) { primitives_DrawLine16( surface, leftCenter.x, leftCenter.y, center.x, center.y, 0x0000 ); } if ( m_numEitherPreReq ) { primitives_DrawLine16( surface, leftCenter.x, leftCenter.y, center.x, center.y, g_colorSet->GetColor(COLOR_BLUE) ); } if ( m_numLeadsTo ) { primitives_DrawLine16( surface, center.x + m_centerButton->Width(), center.y, rightCenter.x, rightCenter.y, 0x0000 ); } for ( i = 0;i < m_numPreReq;i++ ) { POINT l, r; l.x = rect.left + m_preReqButton[i]->X() + m_preReqButton[i]->Width(); l.y = rect.top + m_preReqButton[i]->Y() + m_preReqButton[i]->Height() / 2; r.x = l.x + 5; r.y = l.y; primitives_DrawLine16( surface, l.x, l.y, r.x, r.y, 0x0000 ); primitives_DrawLine16( surface, r.x, r.y, leftCenter.x, leftCenter.y, 0x0000 ); } for ( i = 0;i < m_numEitherPreReq;i++ ) { POINT l, r; l.x = rect.left + m_eitherPreReqButton[i]->X() + m_eitherPreReqButton[i]->Width(); l.y = rect.top + m_eitherPreReqButton[i]->Y() + m_eitherPreReqButton[i]->Height() / 2; r.x = l.x + 5; r.y = l.y; primitives_DrawLine16( surface, l.x, l.y, r.x, r.y, g_colorSet->GetColor(COLOR_BLUE) ); primitives_DrawLine16( surface, r.x, r.y, leftCenter.x, leftCenter.y, g_colorSet->GetColor(COLOR_BLUE) ); } for ( i = 0;i < m_numLeadsTo;i++ ) { POINT l, r; l.x = rect.left + m_leadsToButton[i]->X() - 5; l.y = rect.top + m_leadsToButton[i]->Y() + m_leadsToButton[i]->Height() / 2; r.x = l.x + 5; r.y = l.y; // If leadto advance has center advance as an eitherprerequisite then draw lines BLUE // (rather than black) from center to leadto advance. if(advanceutil_AdvanceHasEitherPrereq(GetLeadsToIndex(i), m_centerIndex)) { primitives_DrawLine16( surface, l.x, l.y, r.x, r.y, g_colorSet->GetColor(COLOR_BLUE) ); primitives_DrawLine16( surface, rightCenter.x, rightCenter.y, l.x, l.y, g_colorSet->GetColor(COLOR_BLUE) ); } else { primitives_DrawLine16( surface, l.x, l.y, r.x, r.y, 0x0000 ); primitives_DrawLine16( surface, rightCenter.x, rightCenter.y, l.x, l.y, 0x0000 ); } } if ( surface == m_window->TheSurface() ) m_window->AddDirtyRect( &rect ); return AUI_ERRCODE_OK; } AUI_ERRCODE Chart::DrawThis( aui_Surface *surface, sint32 x, sint32 y ) { ctp2_Static::DrawThis( surface, x, y ); return AUI_ERRCODE_OK; } sint32 Chart::SetTipInfo( ctp2_Button *button, sint32 index ) { c3_HyperTipWindow *tipWindow = (c3_HyperTipWindow *)button->GetTipWindow(); MBCHAR name[k_MAX_NAME_LEN]; sprintf(name, "%s_HELP", g_theStringDB->GetIdStr(g_theAdvanceDB->Get(index)->m_name)); MBCHAR str[_MAX_PATH]; sprintf( str, "%s", g_theStringDB->GetNameStr(name) ); tipWindow->SetHyperTipText( str ); return(1); } AUI_ERRCODE Chart::Update( sint32 index ) { sint32 i; const MBCHAR *s; m_numPreReq = g_theAdvanceDB->Get(index)->GetNumPrerequisites(); m_numEitherPreReq = g_theAdvanceDB->Get(index)->GetNumEitherPrerequisites(); m_numLeadsTo = 0; for(i = 0; i < g_theAdvanceDB->NumRecords() && m_numLeadsTo < k_MAX_LEADS_TO; i++) { if(i == index) continue; // No more than 4 lead to buttons: prerequisities + eitherprerequisites. if(advanceutil_AdvanceHasPrereq(i, index)) m_leadsToIndex[m_numLeadsTo++] = i; if(advanceutil_AdvanceHasEitherPrereq(i, index)) m_leadsToIndex[m_numLeadsTo++] = i; } sint32 heightBetweenButtons = m_heightBetweenButtons; sint32 buttonHeight = m_centerButton->Height(); sint32 buttonWidth = m_centerButton->Width(); sint32 distanceFromCenter = m_distFromCenter; sint32 xpos = m_distFromSide; sint32 ypos = (Height() - ((m_numPreReq + m_numEitherPreReq) * buttonHeight + ((m_numPreReq + m_numEitherPreReq) - 1) * heightBetweenButtons)) / 2; sint32 curPlayer = g_selected_item->GetVisiblePlayer(); uint8 *adv = g_player[curPlayer]->m_advances->CanResearch(); for ( i = 0; i < m_numPreReq; i++ ) { m_preReqIndex[i] = g_theAdvanceDB->Get(index)->GetPrerequisitesIndex(i); s = g_theAdvanceDB->GetNameStr( m_preReqIndex[i] ); m_preReqButton[i]->Move( xpos, ypos + i*heightBetweenButtons + i*buttonHeight ); m_preReqButton[i]->SetText( s ); m_preReqButton[i]->Show(); aui_Ldl *ldl = g_c3ui->GetLdl(); if (ldl) { ldl->Remove((void *)m_preReqButton[i]); MBCHAR name[k_MAX_NAME_LEN]; sprintf(name, "%s", g_theStringDB->GetIdStr(g_theAdvanceDB->Get(m_preReqIndex[i])->m_name)); ldl->Associate((aui_Control *)m_preReqButton[i], name); } if ( g_player[curPlayer]->HasAdvance(m_preReqIndex[i]) ) { m_preReqColor[i] = COLOR_GREEN; } else { if ( adv[m_preReqIndex[i]] ) { m_preReqColor[i] = COLOR_YELLOW; } else { m_preReqColor[i] = COLOR_RED; } } } while ( i < k_MAX_PREREQ ) { m_preReqButton[i++]->Hide(); } ypos = ypos + m_numPreReq*heightBetweenButtons + m_numPreReq*buttonHeight; for ( i = 0; i < m_numEitherPreReq; i++ ) { m_eitherPreReqIndex[i] = g_theAdvanceDB->Get(index)->GetEitherPrerequisitesIndex(i); s = g_theAdvanceDB->GetNameStr( m_eitherPreReqIndex[i] ); m_eitherPreReqButton[i]->Move( xpos, ypos + i*heightBetweenButtons + i*buttonHeight ); m_eitherPreReqButton[i]->SetText( s ); m_eitherPreReqButton[i]->Show(); aui_Ldl *ldl = g_c3ui->GetLdl(); if (ldl) { ldl->Remove((void *)m_eitherPreReqButton[i]); MBCHAR name[k_MAX_NAME_LEN]; sprintf(name, "%s", g_theStringDB->GetIdStr(g_theAdvanceDB->Get(m_eitherPreReqIndex[i])->m_name)); ldl->Associate((aui_Control *)m_eitherPreReqButton[i], name); } if ( g_player[curPlayer]->HasAdvance(m_eitherPreReqIndex[i]) ) { m_eitherPreReqColor[i] = COLOR_GREEN; } else { if ( adv[m_eitherPreReqIndex[i]] ) { m_eitherPreReqColor[i] = COLOR_YELLOW; } else { m_eitherPreReqColor[i] = COLOR_RED; } } } while ( i < k_MAX_EITHER_PREREQ ) { m_eitherPreReqButton[i++]->Hide(); } xpos += buttonWidth + distanceFromCenter; ypos = (Height() - buttonHeight) / 2; m_centerIndex = index; s = g_theAdvanceDB->GetNameStr( m_centerIndex ); m_centerButton->Move( xpos, ypos ); m_centerButton->SetText( s ); aui_Ldl *ldl = g_c3ui->GetLdl(); if (ldl) { ldl->Remove((void *)m_centerButton); MBCHAR name[k_MAX_NAME_LEN]; sprintf(name, "%s", g_theStringDB->GetIdStr(g_theAdvanceDB->Get(m_centerIndex)->m_name)); ldl->Associate((aui_Control *)m_centerButton, name); } if ( g_player[curPlayer]->HasAdvance(m_centerIndex) ) { m_centerColor = COLOR_GREEN; } else { if ( adv[m_centerIndex] ) { m_centerColor = COLOR_YELLOW; } else { m_centerColor = COLOR_RED; } } xpos += buttonWidth + distanceFromCenter; ypos = (Height() - (m_numLeadsTo * buttonHeight + (m_numLeadsTo - 1) * heightBetweenButtons)) / 2; for ( i = 0;i < m_numLeadsTo;i++ ) { s = g_theAdvanceDB->GetNameStr( m_leadsToIndex[i] ); m_leadsToButton[i]->Move( xpos, ypos + i*heightBetweenButtons + i*buttonHeight ); m_leadsToButton[i]->SetText( s ); m_leadsToButton[i]->Show(); aui_Ldl *ldl = g_c3ui->GetLdl(); if (ldl) { ldl->Remove((void *)m_leadsToButton[i]); MBCHAR name[k_MAX_NAME_LEN]; sprintf(name, "%s", g_theStringDB->GetIdStr(g_theAdvanceDB->Get(m_leadsToIndex[i])->m_name)); ldl->Associate((aui_Control *)m_leadsToButton[i], name); } if ( g_player[curPlayer]->HasAdvance(m_leadsToIndex[i]) ) { m_leadsToColor[i] = COLOR_GREEN; } else { if ( adv[m_leadsToIndex[i]] ) { m_leadsToColor[i] = COLOR_YELLOW; } else { m_leadsToColor[i] = COLOR_RED; } } } while ( i < k_MAX_LEADS_TO) { m_leadsToButton[i++]->Hide(); } delete adv; ShouldDraw(); return AUI_ERRCODE_OK; } void ChartPreReqActionCallback( aui_Control *control, uint32 action, uint32 data, void *cookie ) { if ( action != (uint32)AUI_BUTTON_ACTION_EXECUTE ) return; Chart *chart = (Chart *)cookie; sint32 numPreReq = chart->GetNumPreReq(); for ( sint32 i = 0;i < numPreReq;i++ ) { if ( control->Id() == chart->GetPreReqButton(i)->Id() ) { chart->Update( chart->GetPreReqIndex(i) ); } } } void ChartEitherPreReqActionCallback( aui_Control *control, uint32 action, uint32 data, void *cookie ) { if ( action != (uint32)AUI_BUTTON_ACTION_EXECUTE ) return; Chart *chart = (Chart *)cookie; sint32 numEitherPreReq = chart->GetNumEitherPreReq(); for ( sint32 i = 0;i < numEitherPreReq;i++ ) { if ( control->Id() == chart->GetEitherPreReqButton(i)->Id() ) { chart->Update( chart->GetEitherPreReqIndex(i) ); } } } void ChartLeadsToActionCallback( aui_Control *control, uint32 action, uint32 data, void *cookie ) { if ( action != (uint32)AUI_BUTTON_ACTION_EXECUTE ) return; Chart *chart = (Chart *)cookie; sint32 numLeadsTo = chart->GetNumLeadsTo(); for ( sint32 i = 0;i < numLeadsTo;i++ ) { if ( control->Id() == chart->GetLeadsToButton(i)->Id() ) { chart->Update( chart->GetLeadsToIndex(i) ); } } } void ChartCenterActionCallback( aui_Control *control, uint32 action, uint32 data, void *cookie ) { if ( action != (uint32)AUI_BUTTON_ACTION_EXECUTE ) return; }
; A313115: Coordination sequence Gal.4.43.2 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. ; 1,4,9,14,19,24,29,34,38,42,47,52,57,62,67,72,76,80,85,90,95,100,105,110,114,118,123,128,133,138,143,148,152,156,161,166,171,176,181,186,190,194,199,204,209,214,219,224,228,232 mov $2,1 add $2,$0 mov $3,2 mov $4,$0 lpb $0 sub $0,1 trn $3,$2 sub $2,6 trn $2,2 add $3,2 lpe mov $1,$3 add $1,15 lpb $4 add $1,3 sub $4,1 lpe sub $1,16
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r14 push %r15 push %r9 push %rbp push %rcx push %rdi push %rsi lea addresses_WC_ht+0x19a4a, %rbp nop nop nop nop cmp %rdi, %rdi and $0xffffffffffffffc0, %rbp movaps (%rbp), %xmm7 vpextrq $0, %xmm7, %r9 nop nop cmp %r15, %r15 lea addresses_WT_ht+0x11c26, %r14 nop inc %r9 movw $0x6162, (%r14) nop nop cmp %r9, %r9 lea addresses_WC_ht+0x1834a, %rbp nop nop nop nop cmp %r10, %r10 mov $0x6162636465666768, %r9 movq %r9, %xmm0 movups %xmm0, (%rbp) nop nop nop nop nop sub $64667, %r15 lea addresses_D_ht+0x126e8, %r11 nop nop nop nop and %r9, %r9 movw $0x6162, (%r11) nop nop cmp %r11, %r11 lea addresses_D_ht+0xe9fa, %rsi lea addresses_normal_ht+0x1ed4a, %rdi nop nop nop nop nop add %r10, %r10 mov $126, %rcx rep movsl nop nop nop add %rsi, %rsi lea addresses_WC_ht+0x1d486, %rsi lea addresses_D_ht+0x1bf2a, %rdi nop nop nop xor %r10, %r10 mov $92, %rcx rep movsw nop sub %r9, %r9 lea addresses_D_ht+0x324a, %rdi nop nop nop nop sub %rsi, %rsi movl $0x61626364, (%rdi) nop nop dec %r15 lea addresses_WC_ht+0x77e0, %r11 nop xor $41239, %r10 mov (%r11), %si nop nop nop nop nop add $60843, %rdi pop %rsi pop %rdi pop %rcx pop %rbp pop %r9 pop %r15 pop %r14 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r13 push %r9 push %rax push %rbp push %rcx push %rdx push %rsi // Load lea addresses_PSE+0xd14a, %rcx nop nop nop nop nop xor %rax, %rax mov (%rcx), %rbp sub $17720, %rcx // Store lea addresses_D+0x6b4a, %rax nop nop nop nop nop and %r9, %r9 mov $0x5152535455565758, %rsi movq %rsi, %xmm1 movups %xmm1, (%rax) add $15914, %rdx // Store lea addresses_D+0x6b4a, %rcx nop nop nop sub $24214, %rsi mov $0x5152535455565758, %rdx movq %rdx, (%rcx) nop nop cmp %rdx, %rdx // Faulty Load lea addresses_D+0x6b4a, %rdx nop nop nop xor %r13, %r13 movups (%rdx), %xmm7 vpextrq $1, %xmm7, %rax lea oracles, %rsi and $0xff, %rax shlq $12, %rax mov (%rsi,%rax,1), %rax pop %rsi pop %rdx pop %rcx pop %rbp pop %rax pop %r9 pop %r13 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': False, 'type': 'addresses_D'}, 'OP': 'LOAD'} {'src': {'NT': True, 'AVXalign': False, 'size': 8, 'congruent': 7, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0, 'same': True, 'type': 'addresses_D'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0, 'same': True, 'type': 'addresses_D'}, 'OP': 'STOR'} [Faulty Load] {'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0, 'same': True, 'type': 'addresses_D'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 8, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 10, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 1, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'STOR'} {'src': {'congruent': 1, 'same': False, 'type': 'addresses_D_ht'}, 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'} {'src': {'congruent': 2, 'same': False, 'type': 'addresses_WC_ht'}, 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM'} {'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 6, 'same': True, 'type': 'addresses_D_ht'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
/* * Copyright 2015 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "FakeStreams.h" #include "Resources.h" #include "SkAndroidCodec.h" #include "SkAutoMalloc.h" #include "SkBitmap.h" #include "SkCodec.h" #include "SkCodecImageGenerator.h" #include "SkColorSpace_XYZ.h" #include "SkColorSpacePriv.h" #include "SkData.h" #include "SkFrontBufferedStream.h" #include "SkImageEncoder.h" #include "SkImageEncoderPriv.h" #include "SkMD5.h" #include "SkOSPath.h" #include "SkJpegEncoder.h" #include "SkPngChunkReader.h" #include "SkPngEncoder.h" #include "SkRandom.h" #include "SkStream.h" #include "SkStreamPriv.h" #include "SkWebpEncoder.h" #include "Test.h" #include "png.h" #include "sk_tool_utils.h" #if PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR < 5 // FIXME (scroggo): Google3 needs to be updated to use a newer version of libpng. In // the meantime, we had to break some pieces of SkPngCodec in order to support Google3. // The parts that are broken are likely not used by Google3. #define SK_PNG_DISABLE_TESTS #endif static void md5(const SkBitmap& bm, SkMD5::Digest* digest) { SkASSERT(bm.getPixels()); SkMD5 md5; size_t rowLen = bm.info().bytesPerPixel() * bm.width(); for (int y = 0; y < bm.height(); ++y) { md5.write(bm.getAddr(0, y), rowLen); } md5.finish(*digest); } /** * Compute the digest for bm and compare it to a known good digest. * @param r Reporter to assert that bm's digest matches goodDigest. * @param goodDigest The known good digest to compare to. * @param bm The bitmap to test. */ static void compare_to_good_digest(skiatest::Reporter* r, const SkMD5::Digest& goodDigest, const SkBitmap& bm) { SkMD5::Digest digest; md5(bm, &digest); REPORTER_ASSERT(r, digest == goodDigest); } /** * Test decoding an SkCodec to a particular SkImageInfo. * * Calling getPixels(info) should return expectedResult, and if goodDigest is non nullptr, * the resulting decode should match. */ template<typename Codec> static void test_info(skiatest::Reporter* r, Codec* codec, const SkImageInfo& info, SkCodec::Result expectedResult, const SkMD5::Digest* goodDigest) { SkBitmap bm; bm.allocPixels(info); SkCodec::Result result = codec->getPixels(info, bm.getPixels(), bm.rowBytes()); REPORTER_ASSERT(r, result == expectedResult); if (goodDigest) { compare_to_good_digest(r, *goodDigest, bm); } } SkIRect generate_random_subset(SkRandom* rand, int w, int h) { SkIRect rect; do { rect.fLeft = rand->nextRangeU(0, w); rect.fTop = rand->nextRangeU(0, h); rect.fRight = rand->nextRangeU(0, w); rect.fBottom = rand->nextRangeU(0, h); rect.sort(); } while (rect.isEmpty()); return rect; } static void test_incremental_decode(skiatest::Reporter* r, SkCodec* codec, const SkImageInfo& info, const SkMD5::Digest& goodDigest) { SkBitmap bm; bm.allocPixels(info); REPORTER_ASSERT(r, SkCodec::kSuccess == codec->startIncrementalDecode(info, bm.getPixels(), bm.rowBytes())); REPORTER_ASSERT(r, SkCodec::kSuccess == codec->incrementalDecode()); compare_to_good_digest(r, goodDigest, bm); } // Test in stripes, similar to DM's kStripe_Mode static void test_in_stripes(skiatest::Reporter* r, SkCodec* codec, const SkImageInfo& info, const SkMD5::Digest& goodDigest) { SkBitmap bm; bm.allocPixels(info); bm.eraseColor(SK_ColorYELLOW); const int height = info.height(); // Note that if numStripes does not evenly divide height there will be an extra // stripe. const int numStripes = 4; if (numStripes > height) { // Image is too small. return; } const int stripeHeight = height / numStripes; // Iterate through the image twice. Once to decode odd stripes, and once for even. for (int oddEven = 1; oddEven >= 0; oddEven--) { for (int y = oddEven * stripeHeight; y < height; y += 2 * stripeHeight) { SkIRect subset = SkIRect::MakeLTRB(0, y, info.width(), SkTMin(y + stripeHeight, height)); SkCodec::Options options; options.fSubset = &subset; if (SkCodec::kSuccess != codec->startIncrementalDecode(info, bm.getAddr(0, y), bm.rowBytes(), &options)) { ERRORF(r, "failed to start incremental decode!\ttop: %i\tbottom%i\n", subset.top(), subset.bottom()); return; } if (SkCodec::kSuccess != codec->incrementalDecode()) { ERRORF(r, "failed incremental decode starting from line %i\n", y); return; } } } compare_to_good_digest(r, goodDigest, bm); } template<typename Codec> static void test_codec(skiatest::Reporter* r, Codec* codec, SkBitmap& bm, const SkImageInfo& info, const SkISize& size, SkCodec::Result expectedResult, SkMD5::Digest* digest, const SkMD5::Digest* goodDigest) { REPORTER_ASSERT(r, info.dimensions() == size); bm.allocPixels(info); SkCodec::Result result = codec->getPixels(info, bm.getPixels(), bm.rowBytes()); REPORTER_ASSERT(r, result == expectedResult); md5(bm, digest); if (goodDigest) { REPORTER_ASSERT(r, *digest == *goodDigest); } { // Test decoding to 565 SkImageInfo info565 = info.makeColorType(kRGB_565_SkColorType); if (info.alphaType() == kOpaque_SkAlphaType) { // Decoding to 565 should succeed. SkBitmap bm565; bm565.allocPixels(info565); // This will allow comparison even if the image is incomplete. bm565.eraseColor(SK_ColorBLACK); REPORTER_ASSERT(r, expectedResult == codec->getPixels(info565, bm565.getPixels(), bm565.rowBytes())); SkMD5::Digest digest565; md5(bm565, &digest565); // A dumb client's request for non-opaque should also succeed. for (auto alpha : { kPremul_SkAlphaType, kUnpremul_SkAlphaType }) { info565 = info565.makeAlphaType(alpha); test_info(r, codec, info565, expectedResult, &digest565); } } else { test_info(r, codec, info565, SkCodec::kInvalidConversion, nullptr); } } if (codec->getInfo().colorType() == kGray_8_SkColorType) { SkImageInfo grayInfo = codec->getInfo(); SkBitmap grayBm; grayBm.allocPixels(grayInfo); grayBm.eraseColor(SK_ColorBLACK); REPORTER_ASSERT(r, expectedResult == codec->getPixels(grayInfo, grayBm.getPixels(), grayBm.rowBytes())); SkMD5::Digest grayDigest; md5(grayBm, &grayDigest); for (auto alpha : { kPremul_SkAlphaType, kUnpremul_SkAlphaType }) { grayInfo = grayInfo.makeAlphaType(alpha); test_info(r, codec, grayInfo, expectedResult, &grayDigest); } } // Verify that re-decoding gives the same result. It is interesting to check this after // a decode to 565, since choosing to decode to 565 may result in some of the decode // options being modified. These options should return to their defaults on another // decode to kN32, so the new digest should match the old digest. test_info(r, codec, info, expectedResult, digest); { // Check alpha type conversions if (info.alphaType() == kOpaque_SkAlphaType) { test_info(r, codec, info.makeAlphaType(kUnpremul_SkAlphaType), expectedResult, digest); test_info(r, codec, info.makeAlphaType(kPremul_SkAlphaType), expectedResult, digest); } else { // Decoding to opaque should fail test_info(r, codec, info.makeAlphaType(kOpaque_SkAlphaType), SkCodec::kInvalidConversion, nullptr); SkAlphaType otherAt = info.alphaType(); if (kPremul_SkAlphaType == otherAt) { otherAt = kUnpremul_SkAlphaType; } else { otherAt = kPremul_SkAlphaType; } // The other non-opaque alpha type should always succeed, but not match. test_info(r, codec, info.makeAlphaType(otherAt), expectedResult, nullptr); } } } static bool supports_partial_scanlines(const char path[]) { static const char* const exts[] = { "jpg", "jpeg", "png", "webp" "JPG", "JPEG", "PNG", "WEBP" }; for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { if (SkStrEndsWith(path, exts[i])) { return true; } } return false; } // FIXME: Break up this giant function static void check(skiatest::Reporter* r, const char path[], SkISize size, bool supportsScanlineDecoding, bool supportsSubsetDecoding, bool supportsIncomplete, bool supportsNewScanlineDecoding = false) { std::unique_ptr<SkStream> stream(GetResourceAsStream(path)); if (!stream) { return; } std::unique_ptr<SkCodec> codec(nullptr); bool isIncomplete = supportsIncomplete; if (isIncomplete) { size_t size = stream->getLength(); sk_sp<SkData> data((SkData::MakeFromStream(stream.get(), 2 * size / 3))); codec.reset(SkCodec::NewFromData(data)); } else { codec.reset(SkCodec::NewFromStream(stream.release())); } if (!codec) { ERRORF(r, "Unable to decode '%s'", path); return; } // Test full image decodes with SkCodec SkMD5::Digest codecDigest; const SkImageInfo info = codec->getInfo().makeColorType(kN32_SkColorType); SkBitmap bm; SkCodec::Result expectedResult = isIncomplete ? SkCodec::kIncompleteInput : SkCodec::kSuccess; test_codec(r, codec.get(), bm, info, size, expectedResult, &codecDigest, nullptr); // Scanline decoding follows. if (supportsNewScanlineDecoding && !isIncomplete) { test_incremental_decode(r, codec.get(), info, codecDigest); // This is only supported by codecs that use incremental decoding to // support subset decodes - png and jpeg (once SkJpegCodec is // converted). if (SkStrEndsWith(path, "png") || SkStrEndsWith(path, "PNG")) { test_in_stripes(r, codec.get(), info, codecDigest); } } // Need to call startScanlineDecode() first. REPORTER_ASSERT(r, codec->getScanlines(bm.getAddr(0, 0), 1, 0) == 0); REPORTER_ASSERT(r, !codec->skipScanlines(1)); const SkCodec::Result startResult = codec->startScanlineDecode(info); if (supportsScanlineDecoding) { bm.eraseColor(SK_ColorYELLOW); REPORTER_ASSERT(r, startResult == SkCodec::kSuccess); for (int y = 0; y < info.height(); y++) { const int lines = codec->getScanlines(bm.getAddr(0, y), 1, 0); if (!isIncomplete) { REPORTER_ASSERT(r, 1 == lines); } } // verify that scanline decoding gives the same result. if (SkCodec::kTopDown_SkScanlineOrder == codec->getScanlineOrder()) { compare_to_good_digest(r, codecDigest, bm); } // Cannot continue to decode scanlines beyond the end REPORTER_ASSERT(r, codec->getScanlines(bm.getAddr(0, 0), 1, 0) == 0); // Interrupting a scanline decode with a full decode starts from // scratch REPORTER_ASSERT(r, codec->startScanlineDecode(info) == SkCodec::kSuccess); const int lines = codec->getScanlines(bm.getAddr(0, 0), 1, 0); if (!isIncomplete) { REPORTER_ASSERT(r, lines == 1); } REPORTER_ASSERT(r, codec->getPixels(bm.info(), bm.getPixels(), bm.rowBytes()) == expectedResult); REPORTER_ASSERT(r, codec->getScanlines(bm.getAddr(0, 0), 1, 0) == 0); REPORTER_ASSERT(r, codec->skipScanlines(1) == 0); // Test partial scanline decodes if (supports_partial_scanlines(path) && info.width() >= 3) { SkCodec::Options options; int width = info.width(); int height = info.height(); SkIRect subset = SkIRect::MakeXYWH(2 * (width / 3), 0, width / 3, height); options.fSubset = &subset; const SkCodec::Result partialStartResult = codec->startScanlineDecode(info, &options, nullptr, nullptr); REPORTER_ASSERT(r, partialStartResult == SkCodec::kSuccess); for (int y = 0; y < height; y++) { const int lines = codec->getScanlines(bm.getAddr(0, y), 1, 0); if (!isIncomplete) { REPORTER_ASSERT(r, 1 == lines); } } } } else { REPORTER_ASSERT(r, startResult == SkCodec::kUnimplemented); } // The rest of this function tests decoding subsets, and will decode an arbitrary number of // random subsets. // Do not attempt to decode subsets of an image of only once pixel, since there is no // meaningful subset. if (size.width() * size.height() == 1) { return; } SkRandom rand; SkIRect subset; SkCodec::Options opts; opts.fSubset = &subset; for (int i = 0; i < 5; i++) { subset = generate_random_subset(&rand, size.width(), size.height()); SkASSERT(!subset.isEmpty()); const bool supported = codec->getValidSubset(&subset); REPORTER_ASSERT(r, supported == supportsSubsetDecoding); SkImageInfo subsetInfo = info.makeWH(subset.width(), subset.height()); SkBitmap bm; bm.allocPixels(subsetInfo); const SkCodec::Result result = codec->getPixels(bm.info(), bm.getPixels(), bm.rowBytes(), &opts, nullptr, nullptr); if (supportsSubsetDecoding) { if (expectedResult == SkCodec::kSuccess) { REPORTER_ASSERT(r, result == expectedResult); } else { SkASSERT(expectedResult == SkCodec::kIncompleteInput); REPORTER_ASSERT(r, result == SkCodec::kIncompleteInput || result == SkCodec::kSuccess); } // Webp is the only codec that supports subsets, and it will have modified the subset // to have even left/top. REPORTER_ASSERT(r, SkIsAlign2(subset.fLeft) && SkIsAlign2(subset.fTop)); } else { // No subsets will work. REPORTER_ASSERT(r, result == SkCodec::kUnimplemented); } } // SkAndroidCodec tests if (supportsScanlineDecoding || supportsSubsetDecoding || supportsNewScanlineDecoding) { std::unique_ptr<SkStream> stream(GetResourceAsStream(path)); if (!stream) { return; } std::unique_ptr<SkAndroidCodec> androidCodec(nullptr); if (isIncomplete) { size_t size = stream->getLength(); sk_sp<SkData> data((SkData::MakeFromStream(stream.get(), 2 * size / 3))); androidCodec.reset(SkAndroidCodec::NewFromData(data)); } else { androidCodec.reset(SkAndroidCodec::NewFromStream(stream.release())); } if (!androidCodec) { ERRORF(r, "Unable to decode '%s'", path); return; } SkBitmap bm; SkMD5::Digest androidCodecDigest; test_codec(r, androidCodec.get(), bm, info, size, expectedResult, &androidCodecDigest, &codecDigest); } if (!isIncomplete) { // Test SkCodecImageGenerator std::unique_ptr<SkStream> stream(GetResourceAsStream(path)); sk_sp<SkData> fullData(SkData::MakeFromStream(stream.get(), stream->getLength())); std::unique_ptr<SkImageGenerator> gen( SkCodecImageGenerator::MakeFromEncodedCodec(fullData)); SkBitmap bm; bm.allocPixels(info); REPORTER_ASSERT(r, gen->getPixels(info, bm.getPixels(), bm.rowBytes())); compare_to_good_digest(r, codecDigest, bm); #ifndef SK_PNG_DISABLE_TESTS // Test using SkFrontBufferedStream, as Android does SkStream* bufferedStream = SkFrontBufferedStream::Create( new SkMemoryStream(std::move(fullData)), SkCodec::MinBufferedBytesNeeded()); REPORTER_ASSERT(r, bufferedStream); codec.reset(SkCodec::NewFromStream(bufferedStream)); REPORTER_ASSERT(r, codec); if (codec) { test_info(r, codec.get(), info, SkCodec::kSuccess, &codecDigest); } #endif } // If we've just tested incomplete decodes, let's run the same test again on full decodes. if (isIncomplete) { check(r, path, size, supportsScanlineDecoding, supportsSubsetDecoding, false, supportsNewScanlineDecoding); } } DEF_TEST(Codec_wbmp, r) { check(r, "mandrill.wbmp", SkISize::Make(512, 512), true, false, true); } DEF_TEST(Codec_webp, r) { check(r, "baby_tux.webp", SkISize::Make(386, 395), false, true, true); check(r, "color_wheel.webp", SkISize::Make(128, 128), false, true, true); check(r, "yellow_rose.webp", SkISize::Make(400, 301), false, true, true); } DEF_TEST(Codec_bmp, r) { check(r, "randPixels.bmp", SkISize::Make(8, 8), true, false, true); check(r, "rle.bmp", SkISize::Make(320, 240), true, false, true); } DEF_TEST(Codec_ico, r) { // FIXME: We are not ready to test incomplete ICOs // These two tests examine interestingly different behavior: // Decodes an embedded BMP image check(r, "color_wheel.ico", SkISize::Make(128, 128), true, false, false); // Decodes an embedded PNG image check(r, "google_chrome.ico", SkISize::Make(256, 256), false, false, false, true); } DEF_TEST(Codec_gif, r) { check(r, "box.gif", SkISize::Make(200, 55), false, false, true, true); check(r, "color_wheel.gif", SkISize::Make(128, 128), false, false, true, true); // randPixels.gif is too small to test incomplete check(r, "randPixels.gif", SkISize::Make(8, 8), false, false, false, true); } DEF_TEST(Codec_jpg, r) { check(r, "CMYK.jpg", SkISize::Make(642, 516), true, false, true); check(r, "color_wheel.jpg", SkISize::Make(128, 128), true, false, true); // grayscale.jpg is too small to test incomplete check(r, "grayscale.jpg", SkISize::Make(128, 128), true, false, false); check(r, "mandrill_512_q075.jpg", SkISize::Make(512, 512), true, false, true); // randPixels.jpg is too small to test incomplete check(r, "randPixels.jpg", SkISize::Make(8, 8), true, false, false); } DEF_TEST(Codec_png, r) { check(r, "arrow.png", SkISize::Make(187, 312), false, false, true, true); check(r, "baby_tux.png", SkISize::Make(240, 246), false, false, true, true); check(r, "color_wheel.png", SkISize::Make(128, 128), false, false, true, true); // half-transparent-white-pixel.png is too small to test incomplete check(r, "half-transparent-white-pixel.png", SkISize::Make(1, 1), false, false, false, true); check(r, "mandrill_128.png", SkISize::Make(128, 128), false, false, true, true); check(r, "mandrill_16.png", SkISize::Make(16, 16), false, false, true, true); check(r, "mandrill_256.png", SkISize::Make(256, 256), false, false, true, true); check(r, "mandrill_32.png", SkISize::Make(32, 32), false, false, true, true); check(r, "mandrill_512.png", SkISize::Make(512, 512), false, false, true, true); check(r, "mandrill_64.png", SkISize::Make(64, 64), false, false, true, true); check(r, "plane.png", SkISize::Make(250, 126), false, false, true, true); check(r, "plane_interlaced.png", SkISize::Make(250, 126), false, false, true, true); check(r, "randPixels.png", SkISize::Make(8, 8), false, false, true, true); check(r, "yellow_rose.png", SkISize::Make(400, 301), false, false, true, true); } // Disable RAW tests for Win32. #if defined(SK_CODEC_DECODES_RAW) && (!defined(_WIN32)) DEF_TEST(Codec_raw, r) { check(r, "sample_1mp.dng", SkISize::Make(600, 338), false, false, false); check(r, "sample_1mp_rotated.dng", SkISize::Make(600, 338), false, false, false); check(r, "dng_with_preview.dng", SkISize::Make(600, 338), true, false, false); } #endif static void test_invalid_stream(skiatest::Reporter* r, const void* stream, size_t len) { // Neither of these calls should return a codec. Bots should catch us if we leaked anything. SkCodec* codec = SkCodec::NewFromStream(new SkMemoryStream(stream, len, false)); REPORTER_ASSERT(r, !codec); SkAndroidCodec* androidCodec = SkAndroidCodec::NewFromStream(new SkMemoryStream(stream, len, false)); REPORTER_ASSERT(r, !androidCodec); } // Ensure that SkCodec::NewFromStream handles freeing the passed in SkStream, // even on failure. Test some bad streams. DEF_TEST(Codec_leaks, r) { // No codec should claim this as their format, so this tests SkCodec::NewFromStream. const char nonSupportedStream[] = "hello world"; // The other strings should look like the beginning of a file type, so we'll call some // internal version of NewFromStream, which must also delete the stream on failure. const unsigned char emptyPng[] = { 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a }; const unsigned char emptyJpeg[] = { 0xFF, 0xD8, 0xFF }; const char emptyWebp[] = "RIFF1234WEBPVP"; const char emptyBmp[] = { 'B', 'M' }; const char emptyIco[] = { '\x00', '\x00', '\x01', '\x00' }; const char emptyGif[] = "GIFVER"; test_invalid_stream(r, nonSupportedStream, sizeof(nonSupportedStream)); test_invalid_stream(r, emptyPng, sizeof(emptyPng)); test_invalid_stream(r, emptyJpeg, sizeof(emptyJpeg)); test_invalid_stream(r, emptyWebp, sizeof(emptyWebp)); test_invalid_stream(r, emptyBmp, sizeof(emptyBmp)); test_invalid_stream(r, emptyIco, sizeof(emptyIco)); test_invalid_stream(r, emptyGif, sizeof(emptyGif)); } DEF_TEST(Codec_null, r) { // Attempting to create an SkCodec or an SkAndroidCodec with null should not // crash. SkCodec* codec = SkCodec::NewFromStream(nullptr); REPORTER_ASSERT(r, !codec); SkAndroidCodec* androidCodec = SkAndroidCodec::NewFromStream(nullptr); REPORTER_ASSERT(r, !androidCodec); } static void test_dimensions(skiatest::Reporter* r, const char path[]) { // Create the codec from the resource file std::unique_ptr<SkStream> stream(GetResourceAsStream(path)); if (!stream) { return; } std::unique_ptr<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.release())); if (!codec) { ERRORF(r, "Unable to create codec '%s'", path); return; } // Check that the decode is successful for a variety of scales for (int sampleSize = 1; sampleSize < 32; sampleSize++) { // Scale the output dimensions SkISize scaledDims = codec->getSampledDimensions(sampleSize); SkImageInfo scaledInfo = codec->getInfo() .makeWH(scaledDims.width(), scaledDims.height()) .makeColorType(kN32_SkColorType); // Set up for the decode size_t rowBytes = scaledDims.width() * sizeof(SkPMColor); size_t totalBytes = scaledInfo.getSafeSize(rowBytes); SkAutoTMalloc<SkPMColor> pixels(totalBytes); SkAndroidCodec::AndroidOptions options; options.fSampleSize = sampleSize; SkCodec::Result result = codec->getAndroidPixels(scaledInfo, pixels.get(), rowBytes, &options); REPORTER_ASSERT(r, SkCodec::kSuccess == result); } } // Ensure that onGetScaledDimensions returns valid image dimensions to use for decodes DEF_TEST(Codec_Dimensions, r) { // JPG test_dimensions(r, "CMYK.jpg"); test_dimensions(r, "color_wheel.jpg"); test_dimensions(r, "grayscale.jpg"); test_dimensions(r, "mandrill_512_q075.jpg"); test_dimensions(r, "randPixels.jpg"); // Decoding small images with very large scaling factors is a potential // source of bugs and crashes. We disable these tests in Gold because // tiny images are not very useful to look at. // Here we make sure that we do not crash or access illegal memory when // performing scaled decodes on small images. test_dimensions(r, "1x1.png"); test_dimensions(r, "2x2.png"); test_dimensions(r, "3x3.png"); test_dimensions(r, "3x1.png"); test_dimensions(r, "1x1.png"); test_dimensions(r, "16x1.png"); test_dimensions(r, "1x16.png"); test_dimensions(r, "mandrill_16.png"); // RAW // Disable RAW tests for Win32. #if defined(SK_CODEC_DECODES_RAW) && (!defined(_WIN32)) test_dimensions(r, "sample_1mp.dng"); test_dimensions(r, "sample_1mp_rotated.dng"); test_dimensions(r, "dng_with_preview.dng"); #endif } static void test_invalid(skiatest::Reporter* r, const char path[]) { std::unique_ptr<SkStream> stream(GetResourceAsStream(path)); if (!stream) { return; } std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(stream.release())); REPORTER_ASSERT(r, nullptr == codec); } DEF_TEST(Codec_Empty, r) { // Test images that should not be able to create a codec test_invalid(r, "empty_images/zero-dims.gif"); test_invalid(r, "empty_images/zero-embedded.ico"); test_invalid(r, "empty_images/zero-width.bmp"); test_invalid(r, "empty_images/zero-height.bmp"); test_invalid(r, "empty_images/zero-width.jpg"); test_invalid(r, "empty_images/zero-height.jpg"); test_invalid(r, "empty_images/zero-width.png"); test_invalid(r, "empty_images/zero-height.png"); test_invalid(r, "empty_images/zero-width.wbmp"); test_invalid(r, "empty_images/zero-height.wbmp"); // This image is an ico with an embedded mask-bmp. This is illegal. test_invalid(r, "invalid_images/mask-bmp-ico.ico"); // It is illegal for a webp frame to not be fully contained by the canvas. test_invalid(r, "invalid_images/invalid-offset.webp"); #if defined(SK_CODEC_DECODES_RAW) && (!defined(_WIN32)) test_invalid(r, "empty_images/zero_height.tiff"); #endif } static void test_invalid_parameters(skiatest::Reporter* r, const char path[]) { std::unique_ptr<SkStream> stream(GetResourceAsStream(path)); if (!stream) { return; } std::unique_ptr<SkCodec> decoder(SkCodec::NewFromStream(stream.release())); if (!decoder) { SkDebugf("Missing codec for %s\n", path); return; } const SkImageInfo info = decoder->getInfo().makeColorType(kIndex_8_SkColorType); // This should return kSuccess because kIndex8 is supported. SkPMColor colorStorage[256]; int colorCount; SkCodec::Result result = decoder->startScanlineDecode(info, nullptr, colorStorage, &colorCount); if (SkCodec::kSuccess == result) { // This should return kInvalidParameters because, in kIndex_8 mode, we must pass in a valid // colorPtr and a valid colorCountPtr. result = decoder->startScanlineDecode(info, nullptr, nullptr, nullptr); REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); result = decoder->startScanlineDecode(info); REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); } else if (SkCodec::kUnimplemented == result) { // New method should be supported: SkBitmap bm; bm.allocPixels(info, SkColorTable::Make(colorStorage, 256)); result = decoder->startIncrementalDecode(info, bm.getPixels(), bm.rowBytes(), nullptr, colorStorage, &colorCount); REPORTER_ASSERT(r, SkCodec::kSuccess == result); result = decoder->startIncrementalDecode(info, bm.getPixels(), bm.rowBytes()); REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); } else { // The test is uninteresting if kIndex8 is not supported ERRORF(r, "Should not call test_invalid_parameters for non-Index8 file: %s\n", path); return; } } DEF_TEST(Codec_Params, r) { test_invalid_parameters(r, "index8.png"); test_invalid_parameters(r, "mandrill.wbmp"); } #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED #ifndef SK_PNG_DISABLE_TESTS // reading chunks does not work properly with older versions. // It does not appear that anyone in Google3 is reading chunks. static void codex_test_write_fn(png_structp png_ptr, png_bytep data, png_size_t len) { SkWStream* sk_stream = (SkWStream*)png_get_io_ptr(png_ptr); if (!sk_stream->write(data, len)) { png_error(png_ptr, "sk_write_fn Error!"); } } DEF_TEST(Codec_pngChunkReader, r) { // Create a dummy bitmap. Use unpremul RGBA for libpng. SkBitmap bm; const int w = 1; const int h = 1; const SkImageInfo bmInfo = SkImageInfo::Make(w, h, kRGBA_8888_SkColorType, kUnpremul_SkAlphaType); bm.setInfo(bmInfo); bm.allocPixels(); bm.eraseColor(SK_ColorBLUE); SkMD5::Digest goodDigest; md5(bm, &goodDigest); // Write to a png file. png_structp png = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); REPORTER_ASSERT(r, png); if (!png) { return; } png_infop info = png_create_info_struct(png); REPORTER_ASSERT(r, info); if (!info) { png_destroy_write_struct(&png, nullptr); return; } if (setjmp(png_jmpbuf(png))) { ERRORF(r, "failed writing png"); png_destroy_write_struct(&png, &info); return; } SkDynamicMemoryWStream wStream; png_set_write_fn(png, (void*) (&wStream), codex_test_write_fn, nullptr); png_set_IHDR(png, info, (png_uint_32)w, (png_uint_32)h, 8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); // Create some chunks that match the Android framework's use. static png_unknown_chunk gUnknowns[] = { { "npOl", (png_byte*)"outline", sizeof("outline"), PNG_HAVE_IHDR }, { "npLb", (png_byte*)"layoutBounds", sizeof("layoutBounds"), PNG_HAVE_IHDR }, { "npTc", (png_byte*)"ninePatchData", sizeof("ninePatchData"), PNG_HAVE_IHDR }, }; png_set_keep_unknown_chunks(png, PNG_HANDLE_CHUNK_ALWAYS, (png_byte*)"npOl\0npLb\0npTc\0", 3); png_set_unknown_chunks(png, info, gUnknowns, SK_ARRAY_COUNT(gUnknowns)); #if PNG_LIBPNG_VER < 10600 /* Deal with unknown chunk location bug in 1.5.x and earlier */ png_set_unknown_chunk_location(png, info, 0, PNG_HAVE_IHDR); png_set_unknown_chunk_location(png, info, 1, PNG_HAVE_IHDR); #endif png_write_info(png, info); for (int j = 0; j < h; j++) { png_bytep row = (png_bytep)(bm.getAddr(0, j)); png_write_rows(png, &row, 1); } png_write_end(png, info); png_destroy_write_struct(&png, &info); class ChunkReader : public SkPngChunkReader { public: ChunkReader(skiatest::Reporter* r) : fReporter(r) { this->reset(); } bool readChunk(const char tag[], const void* data, size_t length) override { for (size_t i = 0; i < SK_ARRAY_COUNT(gUnknowns); ++i) { if (!strcmp(tag, (const char*) gUnknowns[i].name)) { // Tag matches. This should have been the first time we see it. REPORTER_ASSERT(fReporter, !fSeen[i]); fSeen[i] = true; // Data and length should match REPORTER_ASSERT(fReporter, length == gUnknowns[i].size); REPORTER_ASSERT(fReporter, !strcmp((const char*) data, (const char*) gUnknowns[i].data)); return true; } } ERRORF(fReporter, "Saw an unexpected unknown chunk."); return true; } bool allHaveBeenSeen() { bool ret = true; for (auto seen : fSeen) { ret &= seen; } return ret; } void reset() { sk_bzero(fSeen, sizeof(fSeen)); } private: skiatest::Reporter* fReporter; // Unowned bool fSeen[3]; }; ChunkReader chunkReader(r); // Now read the file with SkCodec. std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(wStream.detachAsData(), &chunkReader)); REPORTER_ASSERT(r, codec); if (!codec) { return; } // Now compare to the original. SkBitmap decodedBm; decodedBm.setInfo(codec->getInfo()); decodedBm.allocPixels(); SkCodec::Result result = codec->getPixels(codec->getInfo(), decodedBm.getPixels(), decodedBm.rowBytes()); REPORTER_ASSERT(r, SkCodec::kSuccess == result); if (decodedBm.colorType() != bm.colorType()) { SkBitmap tmp; bool success = sk_tool_utils::copy_to(&tmp, bm.colorType(), decodedBm); REPORTER_ASSERT(r, success); if (!success) { return; } tmp.swap(decodedBm); } compare_to_good_digest(r, goodDigest, decodedBm); REPORTER_ASSERT(r, chunkReader.allHaveBeenSeen()); // Decoding again will read the chunks again. chunkReader.reset(); REPORTER_ASSERT(r, !chunkReader.allHaveBeenSeen()); result = codec->getPixels(codec->getInfo(), decodedBm.getPixels(), decodedBm.rowBytes()); REPORTER_ASSERT(r, SkCodec::kSuccess == result); REPORTER_ASSERT(r, chunkReader.allHaveBeenSeen()); } #endif // SK_PNG_DISABLE_TESTS #endif // PNG_READ_UNKNOWN_CHUNKS_SUPPORTED // Stream that can only peek up to a limit class LimitedPeekingMemStream : public SkStream { public: LimitedPeekingMemStream(sk_sp<SkData> data, size_t limit) : fStream(std::move(data)) , fLimit(limit) {} size_t peek(void* buf, size_t bytes) const override { return fStream.peek(buf, SkTMin(bytes, fLimit)); } size_t read(void* buf, size_t bytes) override { return fStream.read(buf, bytes); } bool rewind() override { return fStream.rewind(); } bool isAtEnd() const override { return fStream.isAtEnd(); } private: SkMemoryStream fStream; const size_t fLimit; }; // Disable RAW tests for Win32. #if defined(SK_CODEC_DECODES_RAW) && (!defined(_WIN32)) // Test that the RawCodec works also for not asset stream. This will test the code path using // SkRawBufferedStream instead of SkRawAssetStream. DEF_TEST(Codec_raw_notseekable, r) { const char* path = "dng_with_preview.dng"; SkString fullPath(GetResourcePath(path)); sk_sp<SkData> data(SkData::MakeFromFileName(fullPath.c_str())); if (!data) { SkDebugf("Missing resource '%s'\n", path); return; } std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(new NotAssetMemStream(std::move(data)))); REPORTER_ASSERT(r, codec); test_info(r, codec.get(), codec->getInfo(), SkCodec::kSuccess, nullptr); } #endif // Test that even if webp_parse_header fails to peek enough, it will fall back to read() // + rewind() and succeed. DEF_TEST(Codec_webp_peek, r) { const char* path = "baby_tux.webp"; SkString fullPath(GetResourcePath(path)); auto data = SkData::MakeFromFileName(fullPath.c_str()); if (!data) { SkDebugf("Missing resource '%s'\n", path); return; } // The limit is less than webp needs to peek or read. std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream( new LimitedPeekingMemStream(data, 25))); REPORTER_ASSERT(r, codec); test_info(r, codec.get(), codec->getInfo(), SkCodec::kSuccess, nullptr); // Similarly, a stream which does not peek should still succeed. codec.reset(SkCodec::NewFromStream(new LimitedPeekingMemStream(data, 0))); REPORTER_ASSERT(r, codec); test_info(r, codec.get(), codec->getInfo(), SkCodec::kSuccess, nullptr); } // SkCodec's wbmp decoder was initially unnecessarily restrictive. // It required the second byte to be zero. The wbmp specification allows // a couple of bits to be 1 (so long as they do not overlap with 0x9F). // Test that SkCodec now supports an image with these bits set. DEF_TEST(Codec_wbmp_restrictive, r) { const char* path = "mandrill.wbmp"; std::unique_ptr<SkStream> stream(GetResourceAsStream(path)); if (!stream) { return; } // Modify the stream to contain a second byte with some bits set. auto data = SkCopyStreamToData(stream.get()); uint8_t* writeableData = static_cast<uint8_t*>(data->writable_data()); writeableData[1] = static_cast<uint8_t>(~0x9F); // SkCodec should support this. std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(data)); REPORTER_ASSERT(r, codec); if (!codec) { return; } test_info(r, codec.get(), codec->getInfo(), SkCodec::kSuccess, nullptr); } // wbmp images have a header that can be arbitrarily large, depending on the // size of the image. We cap the size at 65535, meaning we only need to look at // 8 bytes to determine whether we can read the image. This is important // because SkCodec only passes 14 bytes to SkWbmpCodec to determine whether the // image is a wbmp. DEF_TEST(Codec_wbmp_max_size, r) { const unsigned char maxSizeWbmp[] = { 0x00, 0x00, // Header 0x83, 0xFF, 0x7F, // W: 65535 0x83, 0xFF, 0x7F }; // H: 65535 std::unique_ptr<SkStream> stream(new SkMemoryStream(maxSizeWbmp, sizeof(maxSizeWbmp), false)); std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(stream.release())); REPORTER_ASSERT(r, codec); if (!codec) return; REPORTER_ASSERT(r, codec->getInfo().width() == 65535); REPORTER_ASSERT(r, codec->getInfo().height() == 65535); // Now test an image which is too big. Any image with a larger header (i.e. // has bigger width/height) is also too big. const unsigned char tooBigWbmp[] = { 0x00, 0x00, // Header 0x84, 0x80, 0x00, // W: 65536 0x84, 0x80, 0x00 }; // H: 65536 stream.reset(new SkMemoryStream(tooBigWbmp, sizeof(tooBigWbmp), false)); codec.reset(SkCodec::NewFromStream(stream.release())); REPORTER_ASSERT(r, !codec); } DEF_TEST(Codec_jpeg_rewind, r) { const char* path = "mandrill_512_q075.jpg"; sk_sp<SkData> data(GetResourceAsData(path)); if (!data) { return; } data = SkData::MakeSubset(data.get(), 0, data->size() / 2); std::unique_ptr<SkAndroidCodec> codec(SkAndroidCodec::NewFromData(data)); if (!codec) { ERRORF(r, "Unable to create codec '%s'.", path); return; } const int width = codec->getInfo().width(); const int height = codec->getInfo().height(); size_t rowBytes = sizeof(SkPMColor) * width; SkAutoMalloc pixelStorage(height * rowBytes); // Perform a sampled decode. SkAndroidCodec::AndroidOptions opts; opts.fSampleSize = 12; auto sampledInfo = codec->getInfo().makeWH(width / 12, height / 12); auto result = codec->getAndroidPixels(sampledInfo, pixelStorage.get(), rowBytes, &opts); REPORTER_ASSERT(r, SkCodec::kIncompleteInput == result); // Rewind the codec and perform a full image decode. result = codec->getPixels(codec->getInfo(), pixelStorage.get(), rowBytes); REPORTER_ASSERT(r, SkCodec::kIncompleteInput == result); // Now perform a subset decode. { opts.fSampleSize = 1; SkIRect subset = SkIRect::MakeWH(100, 100); opts.fSubset = &subset; result = codec->getAndroidPixels(codec->getInfo().makeWH(100, 100), pixelStorage.get(), rowBytes, &opts); // Though we only have half the data, it is enough to decode this subset. REPORTER_ASSERT(r, SkCodec::kSuccess == result); } // Perform another full image decode. ASAN will detect if we look at the subset when it is // out of scope. This would happen if we depend on the old state in the codec. // This tests two layers of bugs: both SkJpegCodec::readRows and SkCodec::fillIncompleteImage // used to look at the old subset. opts.fSubset = nullptr; result = codec->getAndroidPixels(codec->getInfo(), pixelStorage.get(), rowBytes, &opts); REPORTER_ASSERT(r, SkCodec::kIncompleteInput == result); } static void check_color_xform(skiatest::Reporter* r, const char* path) { std::unique_ptr<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(GetResourceAsStream(path))); SkAndroidCodec::AndroidOptions opts; opts.fSampleSize = 3; const int subsetWidth = codec->getInfo().width() / 2; const int subsetHeight = codec->getInfo().height() / 2; SkIRect subset = SkIRect::MakeWH(subsetWidth, subsetHeight); opts.fSubset = &subset; const int dstWidth = subsetWidth / opts.fSampleSize; const int dstHeight = subsetHeight / opts.fSampleSize; sk_sp<SkData> data = SkData::MakeFromFileName( GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str()); sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeICC(data->data(), data->size()); SkImageInfo dstInfo = codec->getInfo().makeWH(dstWidth, dstHeight) .makeColorType(kN32_SkColorType) .makeColorSpace(colorSpace); size_t rowBytes = dstInfo.minRowBytes(); SkAutoMalloc pixelStorage(dstInfo.getSafeSize(rowBytes)); SkCodec::Result result = codec->getAndroidPixels(dstInfo, pixelStorage.get(), rowBytes, &opts); REPORTER_ASSERT(r, SkCodec::kSuccess == result); } DEF_TEST(Codec_ColorXform, r) { check_color_xform(r, "mandrill_512_q075.jpg"); check_color_xform(r, "mandrill_512.png"); } static bool color_type_match(SkColorType origColorType, SkColorType codecColorType) { switch (origColorType) { case kRGBA_8888_SkColorType: case kBGRA_8888_SkColorType: return kRGBA_8888_SkColorType == codecColorType || kBGRA_8888_SkColorType == codecColorType; default: return origColorType == codecColorType; } } static bool alpha_type_match(SkAlphaType origAlphaType, SkAlphaType codecAlphaType) { switch (origAlphaType) { case kUnpremul_SkAlphaType: case kPremul_SkAlphaType: return kUnpremul_SkAlphaType == codecAlphaType || kPremul_SkAlphaType == codecAlphaType; default: return origAlphaType == codecAlphaType; } } static void check_round_trip(skiatest::Reporter* r, SkCodec* origCodec, const SkImageInfo& info) { SkBitmap bm1; SkPMColor colors[256]; sk_sp<SkColorTable> colorTable1 = SkColorTable::Make(colors, 256); bm1.allocPixels(info, colorTable1); int numColors; SkCodec::Result result = origCodec->getPixels(info, bm1.getPixels(), bm1.rowBytes(), nullptr, const_cast<SkPMColor*>(colorTable1->readColors()), &numColors); // This will fail to update colorTable1->count() but is fine for the purpose of this test. REPORTER_ASSERT(r, SkCodec::kSuccess == result); // Encode the image to png. sk_sp<SkData> data = sk_sp<SkData>(sk_tool_utils::EncodeImageToData(bm1, SkEncodedImageFormat::kPNG, 100)); std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(data)); REPORTER_ASSERT(r, color_type_match(info.colorType(), codec->getInfo().colorType())); REPORTER_ASSERT(r, alpha_type_match(info.alphaType(), codec->getInfo().alphaType())); SkBitmap bm2; sk_sp<SkColorTable> colorTable2 = SkColorTable::Make(colors, 256); bm2.allocPixels(info, colorTable2); result = codec->getPixels(info, bm2.getPixels(), bm2.rowBytes(), nullptr, const_cast<SkPMColor*>(colorTable2->readColors()), &numColors); REPORTER_ASSERT(r, SkCodec::kSuccess == result); SkMD5::Digest d1, d2; md5(bm1, &d1); md5(bm2, &d2); REPORTER_ASSERT(r, d1 == d2); } DEF_TEST(Codec_PngRoundTrip, r) { const char* path = "mandrill_512_q075.jpg"; std::unique_ptr<SkStream> stream(GetResourceAsStream(path)); std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(stream.release())); SkColorType colorTypesOpaque[] = { kRGB_565_SkColorType, kRGBA_8888_SkColorType, kBGRA_8888_SkColorType }; for (SkColorType colorType : colorTypesOpaque) { SkImageInfo newInfo = codec->getInfo().makeColorType(colorType); check_round_trip(r, codec.get(), newInfo); } path = "grayscale.jpg"; stream.reset(GetResourceAsStream(path)); codec.reset(SkCodec::NewFromStream(stream.release())); check_round_trip(r, codec.get(), codec->getInfo()); path = "yellow_rose.png"; stream.reset(GetResourceAsStream(path)); codec.reset(SkCodec::NewFromStream(stream.release())); SkColorType colorTypesWithAlpha[] = { kRGBA_8888_SkColorType, kBGRA_8888_SkColorType }; SkAlphaType alphaTypes[] = { kUnpremul_SkAlphaType, kPremul_SkAlphaType }; for (SkColorType colorType : colorTypesWithAlpha) { for (SkAlphaType alphaType : alphaTypes) { // Set color space to nullptr because color correct premultiplies do not round trip. SkImageInfo newInfo = codec->getInfo().makeColorType(colorType) .makeAlphaType(alphaType) .makeColorSpace(nullptr); check_round_trip(r, codec.get(), newInfo); } } path = "index8.png"; stream.reset(GetResourceAsStream(path)); codec.reset(SkCodec::NewFromStream(stream.release())); for (SkAlphaType alphaType : alphaTypes) { SkImageInfo newInfo = codec->getInfo().makeAlphaType(alphaType) .makeColorSpace(nullptr); check_round_trip(r, codec.get(), newInfo); } } static void test_conversion_possible(skiatest::Reporter* r, const char* path, bool supportsScanlineDecoder, bool supportsIncrementalDecoder) { std::unique_ptr<SkStream> stream(GetResourceAsStream(path)); if (!stream) { return; } std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(stream.release())); if (!codec) { ERRORF(r, "failed to create a codec for %s", path); return; } SkImageInfo infoF16 = codec->getInfo().makeColorType(kRGBA_F16_SkColorType); SkBitmap bm; bm.allocPixels(infoF16); SkCodec::Result result = codec->getPixels(infoF16, bm.getPixels(), bm.rowBytes()); REPORTER_ASSERT(r, SkCodec::kInvalidConversion == result); result = codec->startScanlineDecode(infoF16); if (supportsScanlineDecoder) { REPORTER_ASSERT(r, SkCodec::kInvalidConversion == result); } else { REPORTER_ASSERT(r, SkCodec::kUnimplemented == result); } result = codec->startIncrementalDecode(infoF16, bm.getPixels(), bm.rowBytes()); if (supportsIncrementalDecoder) { REPORTER_ASSERT(r, SkCodec::kInvalidConversion == result); } else { REPORTER_ASSERT(r, SkCodec::kUnimplemented == result); } SkASSERT(SkColorSpace_Base::Type::kXYZ == as_CSB(infoF16.colorSpace())->type()); SkColorSpace_XYZ* csXYZ = static_cast<SkColorSpace_XYZ*>(infoF16.colorSpace()); infoF16 = infoF16.makeColorSpace(csXYZ->makeLinearGamma()); result = codec->getPixels(infoF16, bm.getPixels(), bm.rowBytes()); REPORTER_ASSERT(r, SkCodec::kSuccess == result); result = codec->startScanlineDecode(infoF16); if (supportsScanlineDecoder) { REPORTER_ASSERT(r, SkCodec::kSuccess == result); } else { REPORTER_ASSERT(r, SkCodec::kUnimplemented == result); } result = codec->startIncrementalDecode(infoF16, bm.getPixels(), bm.rowBytes()); if (supportsIncrementalDecoder) { REPORTER_ASSERT(r, SkCodec::kSuccess == result); } else { REPORTER_ASSERT(r, SkCodec::kUnimplemented == result); } } DEF_TEST(Codec_F16ConversionPossible, r) { test_conversion_possible(r, "color_wheel.webp", false, false); test_conversion_possible(r, "mandrill_512_q075.jpg", true, false); test_conversion_possible(r, "yellow_rose.png", false, true); } static void decode_frame(skiatest::Reporter* r, SkCodec* codec, size_t frame) { SkBitmap bm; auto info = codec->getInfo().makeColorType(kN32_SkColorType); bm.allocPixels(info); SkCodec::Options opts; opts.fFrameIndex = frame; REPORTER_ASSERT(r, SkCodec::kSuccess == codec->getPixels(info, bm.getPixels(), bm.rowBytes(), &opts, nullptr, nullptr)); } // For an animated image, we should only read enough to decode the requested // frame if the client never calls getFrameInfo. DEF_TEST(Codec_skipFullParse, r) { auto path = "test640x479.gif"; SkStream* stream(GetResourceAsStream(path)); if (!stream) { return; } // Note that we cheat and hold on to the stream pointer, but SkCodec will // take ownership. We will not refer to the stream after the SkCodec // deletes it. std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(stream)); if (!codec) { ERRORF(r, "Failed to create codec for %s", path); return; } REPORTER_ASSERT(r, stream->hasPosition()); const size_t sizePosition = stream->getPosition(); REPORTER_ASSERT(r, stream->hasLength() && sizePosition < stream->getLength()); // This should read more of the stream, but not the whole stream. decode_frame(r, codec.get(), 0); const size_t positionAfterFirstFrame = stream->getPosition(); REPORTER_ASSERT(r, positionAfterFirstFrame > sizePosition && positionAfterFirstFrame < stream->getLength()); // Again, this should read more of the stream. decode_frame(r, codec.get(), 2); const size_t positionAfterThirdFrame = stream->getPosition(); REPORTER_ASSERT(r, positionAfterThirdFrame > positionAfterFirstFrame && positionAfterThirdFrame < stream->getLength()); // This does not need to read any more of the stream, since it has already // parsed the second frame. decode_frame(r, codec.get(), 1); REPORTER_ASSERT(r, stream->getPosition() == positionAfterThirdFrame); // This should read the rest of the frames. decode_frame(r, codec.get(), 3); const size_t finalPosition = stream->getPosition(); REPORTER_ASSERT(r, finalPosition > positionAfterThirdFrame); // There may be more data in the stream. auto frameInfo = codec->getFrameInfo(); REPORTER_ASSERT(r, frameInfo.size() == 4); REPORTER_ASSERT(r, stream->getPosition() >= finalPosition); } // Only rewinds up to a limit. class LimitedRewindingStream : public SkStream { public: static SkStream* Make(const char path[], size_t limit) { SkStream* stream = GetResourceAsStream(path); if (!stream) { return nullptr; } return new LimitedRewindingStream(stream, limit); } size_t read(void* buffer, size_t size) override { const size_t bytes = fStream->read(buffer, size); fPosition += bytes; return bytes; } bool isAtEnd() const override { return fStream->isAtEnd(); } bool rewind() override { if (fPosition <= fLimit && fStream->rewind()) { fPosition = 0; return true; } return false; } private: std::unique_ptr<SkStream> fStream; const size_t fLimit; size_t fPosition; LimitedRewindingStream(SkStream* stream, size_t limit) : fStream(stream) , fLimit(limit) , fPosition(0) { SkASSERT(fStream); } }; DEF_TEST(Codec_fallBack, r) { // SkAndroidCodec needs to be able to fall back to scanline decoding // if incremental decoding does not work. Make sure this does not // require a rewind. // Formats that currently do not support incremental decoding auto files = { "CMYK.jpg", "color_wheel.ico", "mandrill.wbmp", "randPixels.bmp", }; for (auto file : files) { SkStream* stream = LimitedRewindingStream::Make(file, 14); if (!stream) { SkDebugf("Missing resources (%s). Set --resourcePath.\n", file); return; } std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(stream)); if (!codec) { ERRORF(r, "Failed to create codec for %s,", file); continue; } SkImageInfo info = codec->getInfo().makeColorType(kN32_SkColorType); SkBitmap bm; bm.allocPixels(info); if (SkCodec::kUnimplemented != codec->startIncrementalDecode(info, bm.getPixels(), bm.rowBytes())) { ERRORF(r, "Is scanline decoding now implemented for %s?", file); continue; } // Scanline decoding should not require a rewind. SkCodec::Result result = codec->startScanlineDecode(info); if (SkCodec::kSuccess != result) { ERRORF(r, "Scanline decoding failed for %s with %i", file, result); } } } // This test verifies that we fixed an assert statement that fired when reusing a png codec // after scaling. DEF_TEST(Codec_reusePng, r) { std::unique_ptr<SkStream> stream(GetResourceAsStream("plane.png")); if (!stream) { return; } std::unique_ptr<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.release())); if (!codec) { ERRORF(r, "Failed to create codec\n"); return; } SkAndroidCodec::AndroidOptions opts; opts.fSampleSize = 5; auto size = codec->getSampledDimensions(opts.fSampleSize); auto info = codec->getInfo().makeWH(size.fWidth, size.fHeight).makeColorType(kN32_SkColorType); SkBitmap bm; bm.allocPixels(info); auto result = codec->getAndroidPixels(info, bm.getPixels(), bm.rowBytes(), &opts); REPORTER_ASSERT(r, result == SkCodec::kSuccess); info = codec->getInfo().makeColorType(kN32_SkColorType); bm.allocPixels(info); opts.fSampleSize = 1; result = codec->getAndroidPixels(info, bm.getPixels(), bm.rowBytes(), &opts); REPORTER_ASSERT(r, result == SkCodec::kSuccess); } DEF_TEST(Codec_rowsDecoded, r) { auto file = "plane_interlaced.png"; std::unique_ptr<SkStream> stream(GetResourceAsStream(file)); if (!stream) { return; } // This is enough to read the header etc, but no rows. auto data = SkData::MakeFromStream(stream.get(), 99); std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(data)); if (!codec) { ERRORF(r, "Failed to create codec\n"); return; } auto info = codec->getInfo().makeColorType(kN32_SkColorType); SkBitmap bm; bm.allocPixels(info); auto result = codec->startIncrementalDecode(info, bm.getPixels(), bm.rowBytes()); REPORTER_ASSERT(r, result == SkCodec::kSuccess); // This is an arbitrary value. The important fact is that it is not zero, and rowsDecoded // should get set to zero by incrementalDecode. int rowsDecoded = 77; result = codec->incrementalDecode(&rowsDecoded); REPORTER_ASSERT(r, result == SkCodec::kIncompleteInput); REPORTER_ASSERT(r, rowsDecoded == 0); } static void test_invalid_images(skiatest::Reporter* r, const char* path, SkCodec::Result expectedResult) { auto* stream = GetResourceAsStream(path); if (!stream) { return; } std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(stream)); REPORTER_ASSERT(r, codec); test_info(r, codec.get(), codec->getInfo().makeColorType(kN32_SkColorType), expectedResult, nullptr); } DEF_TEST(Codec_InvalidImages, r) { // ASAN will complain if there is an issue. test_invalid_images(r, "invalid_images/skbug5887.gif", SkCodec::kIncompleteInput); test_invalid_images(r, "invalid_images/many-progressive-scans.jpg", SkCodec::kInvalidInput); test_invalid_images(r, "invalid_images/b33251605.bmp", SkCodec::kIncompleteInput); test_invalid_images(r, "invalid_images/bad_palette.png", SkCodec::kInvalidInput); } static void test_invalid_header(skiatest::Reporter* r, const char* path) { SkString resourcePath = GetResourcePath(path); std::unique_ptr<SkFILEStream> stream(new SkFILEStream(resourcePath.c_str())); if (!stream->isValid()) { return; } std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(stream.release())); REPORTER_ASSERT(r, !codec); } DEF_TEST(Codec_InvalidHeader, r) { test_invalid_header(r, "invalid_images/int_overflow.ico"); // These files report values that have caused problems with SkFILEStreams. // They are invalid, and should not create SkCodecs. test_invalid_header(r, "invalid_images/b33651913.bmp"); test_invalid_header(r, "invalid_images/b34778578.bmp"); } DEF_TEST(Codec_InvalidAnimated, r) { // ASAN will complain if there is an issue. auto path = "invalid_images/skbug6046.gif"; auto* stream = GetResourceAsStream(path); if (!stream) { return; } std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(stream)); REPORTER_ASSERT(r, codec); if (!codec) { return; } const auto info = codec->getInfo().makeColorType(kN32_SkColorType); SkBitmap bm; bm.allocPixels(info); auto frameInfos = codec->getFrameInfo(); SkCodec::Options opts; for (int i = 0; static_cast<size_t>(i) < frameInfos.size(); i++) { opts.fFrameIndex = i; opts.fHasPriorFrame = frameInfos[i].fRequiredFrame == i - 1; auto result = codec->startIncrementalDecode(info, bm.getPixels(), bm.rowBytes(), &opts); if (result != SkCodec::kSuccess) { ERRORF(r, "Failed to start decoding frame %i (out of %i) with error %i\n", i, frameInfos.size(), result); continue; } codec->incrementalDecode(); } } static void encode_format(SkDynamicMemoryWStream* stream, const SkPixmap& pixmap, SkTransferFunctionBehavior unpremulBehavior, SkEncodedImageFormat format) { SkPngEncoder::Options pngOptions; SkWebpEncoder::Options webpOptions; pngOptions.fUnpremulBehavior = unpremulBehavior; webpOptions.fUnpremulBehavior = unpremulBehavior; switch (format) { case SkEncodedImageFormat::kPNG: SkPngEncoder::Encode(stream, pixmap, pngOptions); break; case SkEncodedImageFormat::kJPEG: SkJpegEncoder::Encode(stream, pixmap, SkJpegEncoder::Options()); break; case SkEncodedImageFormat::kWEBP: SkWebpEncoder::Encode(stream, pixmap, webpOptions); break; default: SkASSERT(false); break; } } static void test_encode_icc(skiatest::Reporter* r, SkEncodedImageFormat format, SkTransferFunctionBehavior unpremulBehavior) { // Test with sRGB color space. SkBitmap srgbBitmap; SkImageInfo srgbInfo = SkImageInfo::MakeS32(1, 1, kOpaque_SkAlphaType); srgbBitmap.allocPixels(srgbInfo); *srgbBitmap.getAddr32(0, 0) = 0; SkPixmap pixmap; srgbBitmap.peekPixels(&pixmap); SkDynamicMemoryWStream srgbBuf; encode_format(&srgbBuf, pixmap, unpremulBehavior, format); sk_sp<SkData> srgbData = srgbBuf.detachAsData(); std::unique_ptr<SkCodec> srgbCodec(SkCodec::NewFromData(srgbData)); REPORTER_ASSERT(r, srgbCodec->getInfo().colorSpace() == SkColorSpace::MakeSRGB().get()); // Test with P3 color space. SkDynamicMemoryWStream p3Buf; sk_sp<SkColorSpace> p3 = SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma, SkColorSpace::kDCIP3_D65_Gamut); pixmap.setColorSpace(p3); encode_format(&p3Buf, pixmap, unpremulBehavior, format); sk_sp<SkData> p3Data = p3Buf.detachAsData(); std::unique_ptr<SkCodec> p3Codec(SkCodec::NewFromData(p3Data)); REPORTER_ASSERT(r, p3Codec->getInfo().colorSpace()->gammaCloseToSRGB()); SkMatrix44 mat0(SkMatrix44::kUninitialized_Constructor); SkMatrix44 mat1(SkMatrix44::kUninitialized_Constructor); bool success = p3->toXYZD50(&mat0); REPORTER_ASSERT(r, success); success = p3Codec->getInfo().colorSpace()->toXYZD50(&mat1); REPORTER_ASSERT(r, success); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { REPORTER_ASSERT(r, color_space_almost_equal(mat0.get(i, j), mat1.get(i, j))); } } } DEF_TEST(Codec_EncodeICC, r) { test_encode_icc(r, SkEncodedImageFormat::kPNG, SkTransferFunctionBehavior::kRespect); test_encode_icc(r, SkEncodedImageFormat::kJPEG, SkTransferFunctionBehavior::kRespect); test_encode_icc(r, SkEncodedImageFormat::kWEBP, SkTransferFunctionBehavior::kRespect); test_encode_icc(r, SkEncodedImageFormat::kPNG, SkTransferFunctionBehavior::kIgnore); test_encode_icc(r, SkEncodedImageFormat::kJPEG, SkTransferFunctionBehavior::kIgnore); test_encode_icc(r, SkEncodedImageFormat::kWEBP, SkTransferFunctionBehavior::kIgnore); }
; A189894: Number of isosceles right triangles on a 2n X (n+1) grid. ; 4,50,208,582,1308,2556,4528,7460,11620,17310,24864,34650,47068,62552,81568,104616,132228,164970,203440,248270,300124,359700,427728,504972,592228,690326,800128,922530,1058460,1208880,1374784,1557200,1757188,1975842,2214288,2473686,2755228,3060140,3389680,3745140,4127844,4539150,4980448,5453162,5958748,6498696,7074528,7687800,8340100,9033050,9768304,10547550,11372508,12244932,13166608,14139356,15165028,16245510,17382720,18578610,19835164,21154400,22538368,23989152,25508868,27099666,28763728 mov $11,$0 mov $12,$0 add $12,1 lpb $12 mov $0,$11 mov $9,0 sub $12,1 sub $0,$12 mov $8,$0 mov $10,$0 add $10,1 lpb $10 mov $0,$8 mov $6,0 sub $10,1 sub $0,$10 mov $5,$0 mov $7,$0 add $7,1 lpb $7 mov $0,$5 sub $7,1 sub $0,$7 mul $0,2 mov $2,$0 pow $0,0 div $2,2 mul $2,33 lpb $0 sub $0,1 mov $4,2 add $4,$2 add $4,1 div $4,2 add $4,1 mov $3,$4 mul $3,2 lpe add $6,$3 lpe add $9,$6 lpe add $1,$9 lpe mov $0,$1
#pragma once #include <futurepia/protocol/asset.hpp> namespace futurepia { namespace chain { namespace util { using futurepia::protocol::asset; using futurepia::protocol::price; inline asset to_snac( const price& p, const asset& pia ) { FC_ASSERT( pia.symbol == PIA_SYMBOL ); if( p.is_null() ) return asset( 0, SNAC_SYMBOL ); return pia * p; } inline asset to_pia( const price& p, const asset& snac ) { FC_ASSERT( snac.symbol == SNAC_SYMBOL ); if( p.is_null() ) return asset( 0, PIA_SYMBOL ); return snac * p; } } } }
// Copyright (c) 2018 Microsoft Corporation // Licensed under the MIT license. // Author: Paul Koch <code@koch.ninja> #include "PrecompiledHeader.h" #include <stddef.h> // size_t, ptrdiff_t #include "ebm_native.h" // FloatEbmType #include "EbmInternal.h" // INLINE_ALWAYS #include "Logging.h" // EBM_ASSERT & LOG #include "SegmentedTensor.h" #include "EbmStatisticUtils.h" #include "FeatureAtomic.h" #include "FeatureGroup.h" #include "HistogramTargetEntry.h" #include "HistogramBucket.h" #include "Booster.h" #include "TensorTotalsSum.h" template<ptrdiff_t compilerLearningTypeOrCountTargetClasses> static FloatEbmType SweepMultiDiemensional( const HistogramBucket<IsClassification(compilerLearningTypeOrCountTargetClasses)> * const aHistogramBuckets, const FeatureGroup * const pFeatureGroup, size_t * const aiPoint, const size_t directionVectorLow, const unsigned int iDimensionSweep, const size_t cSamplesRequiredForChildSplitMin, const ptrdiff_t runtimeLearningTypeOrCountTargetClasses, HistogramBucket<IsClassification(compilerLearningTypeOrCountTargetClasses)> * const pHistogramBucketBestAndTemp, size_t * const piBestCut #ifndef NDEBUG , const HistogramBucket<IsClassification(compilerLearningTypeOrCountTargetClasses)> * const aHistogramBucketsDebugCopy , const unsigned char * const aHistogramBucketsEndDebug #endif // NDEBUG ) { constexpr bool bClassification = IsClassification(compilerLearningTypeOrCountTargetClasses); // don't LOG this! It would create way too much chatter! // TODO : optimize this function EBM_ASSERT(1 <= pFeatureGroup->GetCountFeatures()); EBM_ASSERT(iDimensionSweep < pFeatureGroup->GetCountFeatures()); EBM_ASSERT(0 == (directionVectorLow & (size_t { 1 } << iDimensionSweep))); const ptrdiff_t learningTypeOrCountTargetClasses = GET_LEARNING_TYPE_OR_COUNT_TARGET_CLASSES( compilerLearningTypeOrCountTargetClasses, runtimeLearningTypeOrCountTargetClasses ); const size_t cVectorLength = GetVectorLength(learningTypeOrCountTargetClasses); EBM_ASSERT(!GetHistogramBucketSizeOverflow(bClassification, cVectorLength)); // we're accessing allocated memory const size_t cBytesPerHistogramBucket = GetHistogramBucketSize(bClassification, cVectorLength); EBM_ASSERT(!IsMultiplyError(2, cBytesPerHistogramBucket)); // we're accessing allocated memory const size_t cBytesPerTwoHistogramBuckets = cBytesPerHistogramBucket << 1; size_t * const piBin = &aiPoint[iDimensionSweep]; *piBin = 0; size_t directionVectorHigh = directionVectorLow | size_t { 1 } << iDimensionSweep; const size_t cBins = pFeatureGroup->GetFeatureGroupEntries()[iDimensionSweep].m_pFeature->GetCountBins(); EBM_ASSERT(2 <= cBins); size_t iBestCut = 0; HistogramBucket<bClassification> * const pTotalsLow = GetHistogramBucketByIndex<bClassification>(cBytesPerHistogramBucket, pHistogramBucketBestAndTemp, 2); ASSERT_BINNED_BUCKET_OK(cBytesPerHistogramBucket, pTotalsLow, aHistogramBucketsEndDebug); HistogramBucket<bClassification> * const pTotalsHigh = GetHistogramBucketByIndex<bClassification>(cBytesPerHistogramBucket, pHistogramBucketBestAndTemp, 3); ASSERT_BINNED_BUCKET_OK(cBytesPerHistogramBucket, pTotalsHigh, aHistogramBucketsEndDebug); EBM_ASSERT(0 < cSamplesRequiredForChildSplitMin); FloatEbmType bestSplit = k_illegalGain; size_t iBin = 0; do { *piBin = iBin; TensorTotalsSum<compilerLearningTypeOrCountTargetClasses, 2>( runtimeLearningTypeOrCountTargetClasses, pFeatureGroup, aHistogramBuckets, aiPoint, directionVectorLow, pTotalsLow #ifndef NDEBUG , aHistogramBucketsDebugCopy , aHistogramBucketsEndDebug #endif // NDEBUG ); if(LIKELY(cSamplesRequiredForChildSplitMin <= pTotalsLow->GetCountSamplesInBucket())) { TensorTotalsSum<compilerLearningTypeOrCountTargetClasses, 2>( runtimeLearningTypeOrCountTargetClasses, pFeatureGroup, aHistogramBuckets, aiPoint, directionVectorHigh, pTotalsHigh #ifndef NDEBUG , aHistogramBucketsDebugCopy , aHistogramBucketsEndDebug #endif // NDEBUG ); if(LIKELY(cSamplesRequiredForChildSplitMin <= pTotalsHigh->GetCountSamplesInBucket())) { FloatEbmType splittingScore = FloatEbmType { 0 }; EBM_ASSERT(0 < pTotalsLow->GetCountSamplesInBucket()); EBM_ASSERT(0 < pTotalsHigh->GetCountSamplesInBucket()); FloatEbmType cLowSamplesInBucket = static_cast<FloatEbmType>(pTotalsLow->GetCountSamplesInBucket()); FloatEbmType cHighSamplesInBucket = static_cast<FloatEbmType>(pTotalsHigh->GetCountSamplesInBucket()); HistogramBucketVectorEntry<bClassification> * const pHistogramBucketVectorEntryLow = pTotalsLow->GetHistogramBucketVectorEntry(); HistogramBucketVectorEntry<bClassification> * const pHistogramBucketVectorEntryHigh = pTotalsHigh->GetHistogramBucketVectorEntry(); for(size_t iVector = 0; iVector < cVectorLength; ++iVector) { // TODO : we can make this faster by doing the division in ComputeNodeSplittingScore after we add all the numerators // (but only do this after we've determined the best node splitting score for classification, and the NewtonRaphsonStep for gain const FloatEbmType splittingScoreUpdate1 = EbmStatistics::ComputeNodeSplittingScore( pHistogramBucketVectorEntryLow[iVector].m_sumResidualError, cLowSamplesInBucket); EBM_ASSERT(std::isnan(splittingScoreUpdate1) || FloatEbmType { 0 } <= splittingScoreUpdate1); splittingScore += splittingScoreUpdate1; const FloatEbmType splittingScoreUpdate2 = EbmStatistics::ComputeNodeSplittingScore( pHistogramBucketVectorEntryHigh[iVector].m_sumResidualError, cHighSamplesInBucket); EBM_ASSERT(std::isnan(splittingScoreUpdate2) || FloatEbmType { 0 } <= splittingScoreUpdate2); splittingScore += splittingScoreUpdate2; } EBM_ASSERT(std::isnan(splittingScore) || FloatEbmType { 0 } <= splittingScore); // sumation of positive numbers should be positive // if we get a NaN result, we'd like to propagate it by making bestSplit NaN. The rules for NaN values say that non equality comparisons are // all false so, let's flip this comparison such that it should be true for NaN values. If the compiler violates NaN comparions rules, // no big deal. NaN values will get us soon and shut down boosting. if(UNLIKELY(/* DO NOT CHANGE THIS WITHOUT READING THE ABOVE. WE DO THIS STRANGE COMPARISON FOR NaN values*/ !(splittingScore <= bestSplit))) { bestSplit = splittingScore; iBestCut = iBin; ASSERT_BINNED_BUCKET_OK( cBytesPerHistogramBucket, GetHistogramBucketByIndex<bClassification>( cBytesPerHistogramBucket, pHistogramBucketBestAndTemp, 1 ), aHistogramBucketsEndDebug ); ASSERT_BINNED_BUCKET_OK( cBytesPerHistogramBucket, GetHistogramBucketByIndex<bClassification>(cBytesPerHistogramBucket, pTotalsLow, 1), aHistogramBucketsEndDebug ); memcpy(pHistogramBucketBestAndTemp, pTotalsLow, cBytesPerTwoHistogramBuckets); // this copies both pTotalsLow and pTotalsHigh } else { EBM_ASSERT(!std::isnan(splittingScore)); } } } ++iBin; } while(iBin < cBins - 1); *piBestCut = iBestCut; EBM_ASSERT(std::isnan(bestSplit) || bestSplit == k_illegalGain || FloatEbmType { 0 } <= bestSplit); // sumation of positive numbers should be positive return bestSplit; } template<ptrdiff_t compilerLearningTypeOrCountTargetClasses> class FindBestBoostingSplitPairsInternal final { public: FindBestBoostingSplitPairsInternal() = delete; // this is a static class. Do not construct WARNING_PUSH WARNING_DISABLE_UNINITIALIZED_LOCAL_VARIABLE static bool Func( EbmBoostingState * const pEbmBoostingState, const FeatureGroup * const pFeatureGroup, const size_t cSamplesRequiredForChildSplitMin, HistogramBucketBase * pAuxiliaryBucketZoneBase, HistogramBucketBase * const pTotalBase, HistogramBucketBase * const aHistogramBucketsBase, SegmentedTensor * const pSmallChangeToModelOverwriteSingleSamplingSet, FloatEbmType * const pTotalGain #ifndef NDEBUG , const HistogramBucketBase * const aHistogramBucketsDebugCopyBase , const unsigned char * const aHistogramBucketsEndDebug #endif // NDEBUG ) { constexpr bool bClassification = IsClassification(compilerLearningTypeOrCountTargetClasses); const ptrdiff_t runtimeLearningTypeOrCountTargetClasses = pEbmBoostingState->GetRuntimeLearningTypeOrCountTargetClasses(); const ptrdiff_t learningTypeOrCountTargetClasses = GET_LEARNING_TYPE_OR_COUNT_TARGET_CLASSES( compilerLearningTypeOrCountTargetClasses, pEbmBoostingState->GetRuntimeLearningTypeOrCountTargetClasses() ); const size_t cVectorLength = GetVectorLength(learningTypeOrCountTargetClasses); const size_t cBytesPerHistogramBucket = GetHistogramBucketSize(bClassification, cVectorLength); HistogramBucket<IsClassification(compilerLearningTypeOrCountTargetClasses)> * pAuxiliaryBucketZone = pAuxiliaryBucketZoneBase->GetHistogramBucket<bClassification>(); HistogramBucket<IsClassification(compilerLearningTypeOrCountTargetClasses)> * const pTotal = pTotalBase->GetHistogramBucket<bClassification>(); HistogramBucket<IsClassification(compilerLearningTypeOrCountTargetClasses)> * const aHistogramBuckets = aHistogramBucketsBase->GetHistogramBucket<bClassification>(); #ifndef NDEBUG const HistogramBucket<IsClassification(compilerLearningTypeOrCountTargetClasses)> * const aHistogramBucketsDebugCopy = aHistogramBucketsDebugCopyBase->GetHistogramBucket<bClassification>(); #endif // NDEBUG size_t aiStart[k_cDimensionsMax]; FloatEbmType splittingScore; const size_t cBinsDimension1 = pFeatureGroup->GetFeatureGroupEntries()[0].m_pFeature->GetCountBins(); const size_t cBinsDimension2 = pFeatureGroup->GetFeatureGroupEntries()[1].m_pFeature->GetCountBins(); EBM_ASSERT(2 <= cBinsDimension1); EBM_ASSERT(2 <= cBinsDimension2); FloatEbmType bestSplittingScore = k_illegalGain; size_t cutFirst1Best; size_t cutFirst1LowBest; size_t cutFirst1HighBest; HistogramBucket<bClassification> * pTotals1LowLowBest = GetHistogramBucketByIndex<bClassification>(cBytesPerHistogramBucket, pAuxiliaryBucketZone, 0); HistogramBucket<bClassification> * pTotals1LowHighBest = GetHistogramBucketByIndex<bClassification>(cBytesPerHistogramBucket, pAuxiliaryBucketZone, 1); HistogramBucket<bClassification> * pTotals1HighLowBest = GetHistogramBucketByIndex<bClassification>(cBytesPerHistogramBucket, pAuxiliaryBucketZone, 2); HistogramBucket<bClassification> * pTotals1HighHighBest = GetHistogramBucketByIndex<bClassification>(cBytesPerHistogramBucket, pAuxiliaryBucketZone, 3); ASSERT_BINNED_BUCKET_OK(cBytesPerHistogramBucket, pTotal, aHistogramBucketsEndDebug); EBM_ASSERT(0 < cSamplesRequiredForChildSplitMin); FloatEbmType splittingScoreParent = FloatEbmType { 0 }; EBM_ASSERT(0 < pTotal->GetCountSamplesInBucket()); const FloatEbmType cSamplesInParentBucket = static_cast<FloatEbmType>(pTotal->GetCountSamplesInBucket()); HistogramBucketVectorEntry<bClassification> * const pHistogramBucketVectorEntryTotal = pTotal->GetHistogramBucketVectorEntry(); for(size_t iVector = 0; iVector < cVectorLength; ++iVector) { // TODO : we can make this faster by doing the division in ComputeNodeSplittingScoreParent after we add all the numerators // (but only do this after we've determined the best node splitting score for classification, and the NewtonRaphsonStep for gain const FloatEbmType splittingScoreParentUpdate = EbmStatistics::ComputeNodeSplittingScore( pHistogramBucketVectorEntryTotal[iVector].m_sumResidualError, cSamplesInParentBucket ); EBM_ASSERT(std::isnan(splittingScoreParentUpdate) || FloatEbmType { 0 } <= splittingScoreParentUpdate); splittingScoreParent += splittingScoreParentUpdate; } EBM_ASSERT(std::isnan(splittingScoreParent) || FloatEbmType { 0 } <= splittingScoreParent); // sumation of positive numbers should be positive LOG_0(TraceLevelVerbose, "BoostMultiDimensional Starting FIRST bin sweep loop"); size_t iBin1 = 0; do { aiStart[0] = iBin1; splittingScore = FloatEbmType { 0 }; size_t cutSecond1LowBest; HistogramBucket<bClassification> * pTotals2LowLowBest = GetHistogramBucketByIndex<bClassification>(cBytesPerHistogramBucket, pAuxiliaryBucketZone, 4); HistogramBucket<bClassification> * pTotals2LowHighBest = GetHistogramBucketByIndex<bClassification>(cBytesPerHistogramBucket, pAuxiliaryBucketZone, 5); const FloatEbmType splittingScoreNew1 = SweepMultiDiemensional<compilerLearningTypeOrCountTargetClasses>( aHistogramBuckets, pFeatureGroup, aiStart, 0x0, 1, cSamplesRequiredForChildSplitMin, runtimeLearningTypeOrCountTargetClasses, pTotals2LowLowBest, &cutSecond1LowBest #ifndef NDEBUG , aHistogramBucketsDebugCopy , aHistogramBucketsEndDebug #endif // NDEBUG ); // if we get a NaN result, we'd like to propagate it by making bestSplit NaN. The rules for NaN values say that non equality comparisons are all // false so, let's flip this comparison such that it should be true for NaN values. If the compiler violates NaN comparions rules, no big deal. // NaN values will get us soon and shut down boosting. if(LIKELY(/* DO NOT CHANGE THIS WITHOUT READING THE ABOVE. WE DO THIS STRANGE COMPARISON FOR NaN values*/ !(k_illegalGain == splittingScoreNew1))) { EBM_ASSERT(std::isnan(splittingScoreNew1) || FloatEbmType { 0 } <= splittingScoreNew1); splittingScore += splittingScoreNew1; size_t cutSecond1HighBest; HistogramBucket<bClassification> * pTotals2HighLowBest = GetHistogramBucketByIndex<bClassification>(cBytesPerHistogramBucket, pAuxiliaryBucketZone, 8); HistogramBucket<bClassification> * pTotals2HighHighBest = GetHistogramBucketByIndex<bClassification>(cBytesPerHistogramBucket, pAuxiliaryBucketZone, 9); const FloatEbmType splittingScoreNew2 = SweepMultiDiemensional<compilerLearningTypeOrCountTargetClasses>( aHistogramBuckets, pFeatureGroup, aiStart, 0x1, 1, cSamplesRequiredForChildSplitMin, runtimeLearningTypeOrCountTargetClasses, pTotals2HighLowBest, &cutSecond1HighBest #ifndef NDEBUG , aHistogramBucketsDebugCopy , aHistogramBucketsEndDebug #endif // NDEBUG ); // if we get a NaN result, we'd like to propagate it by making bestSplit NaN. The rules for NaN values say that non equality comparisons are // all false so, let's flip this comparison such that it should be true for NaN values. If the compiler violates NaN comparions rules, // no big deal. NaN values will get us soon and shut down boosting. if(LIKELY(/* DO NOT CHANGE THIS WITHOUT READING THE ABOVE. WE DO THIS STRANGE COMPARISON FOR NaN values*/ !(k_illegalGain == splittingScoreNew2))) { EBM_ASSERT(std::isnan(splittingScoreNew2) || FloatEbmType { 0 } <= splittingScoreNew2); splittingScore += splittingScoreNew2; // if we get a NaN result, we'd like to propagate it by making bestSplit NaN. The rules for NaN values say that non equality comparisons // are all false so, let's flip this comparison such that it should be true for NaN values. If the compiler violates NaN comparions rules, // no big deal. NaN values will get us soon and shut down boosting. if(UNLIKELY(/* DO NOT CHANGE THIS WITHOUT READING THE ABOVE. WE DO THIS STRANGE COMPARISON FOR NaN values*/ !(splittingScore <= bestSplittingScore))) { bestSplittingScore = splittingScore; cutFirst1Best = iBin1; cutFirst1LowBest = cutSecond1LowBest; cutFirst1HighBest = cutSecond1HighBest; pTotals1LowLowBest->Copy(*pTotals2LowLowBest, cVectorLength); pTotals1LowHighBest->Copy(*pTotals2LowHighBest, cVectorLength); pTotals1HighLowBest->Copy(*pTotals2HighLowBest, cVectorLength); pTotals1HighHighBest->Copy(*pTotals2HighHighBest, cVectorLength); } else { EBM_ASSERT(!std::isnan(splittingScore)); } } else { EBM_ASSERT(!std::isnan(splittingScoreNew2)); EBM_ASSERT(k_illegalGain == splittingScoreNew2); } } else { EBM_ASSERT(!std::isnan(splittingScoreNew1)); EBM_ASSERT(k_illegalGain == splittingScoreNew1); } ++iBin1; } while(iBin1 < cBinsDimension1 - 1); bool bCutFirst2 = false; size_t cutFirst2Best; size_t cutFirst2LowBest; size_t cutFirst2HighBest; HistogramBucket<bClassification> * pTotals2LowLowBest = GetHistogramBucketByIndex<bClassification>(cBytesPerHistogramBucket, pAuxiliaryBucketZone, 12); HistogramBucket<bClassification> * pTotals2LowHighBest = GetHistogramBucketByIndex<bClassification>(cBytesPerHistogramBucket, pAuxiliaryBucketZone, 13); HistogramBucket<bClassification> * pTotals2HighLowBest = GetHistogramBucketByIndex<bClassification>(cBytesPerHistogramBucket, pAuxiliaryBucketZone, 14); HistogramBucket<bClassification> * pTotals2HighHighBest = GetHistogramBucketByIndex<bClassification>(cBytesPerHistogramBucket, pAuxiliaryBucketZone, 15); LOG_0(TraceLevelVerbose, "BoostMultiDimensional Starting SECOND bin sweep loop"); size_t iBin2 = 0; do { aiStart[1] = iBin2; splittingScore = FloatEbmType { 0 }; size_t cutSecond2LowBest; HistogramBucket<bClassification> * pTotals1LowLowBestInner = GetHistogramBucketByIndex<bClassification>(cBytesPerHistogramBucket, pAuxiliaryBucketZone, 16); HistogramBucket<bClassification> * pTotals1LowHighBestInner = GetHistogramBucketByIndex<bClassification>(cBytesPerHistogramBucket, pAuxiliaryBucketZone, 17); const FloatEbmType splittingScoreNew1 = SweepMultiDiemensional<compilerLearningTypeOrCountTargetClasses>( aHistogramBuckets, pFeatureGroup, aiStart, 0x0, 0, cSamplesRequiredForChildSplitMin, runtimeLearningTypeOrCountTargetClasses, pTotals1LowLowBestInner, &cutSecond2LowBest #ifndef NDEBUG , aHistogramBucketsDebugCopy , aHistogramBucketsEndDebug #endif // NDEBUG ); // if we get a NaN result, we'd like to propagate it by making bestSplit NaN. The rules for NaN values say that non equality comparisons are // all false so, let's flip this comparison such that it should be true for NaN values. If the compiler violates NaN comparions rules, no big deal. // NaN values will get us soon and shut down boosting. if(LIKELY(/* DO NOT CHANGE THIS WITHOUT READING THE ABOVE. WE DO THIS STRANGE COMPARISON FOR NaN values*/ !(k_illegalGain == splittingScoreNew1))) { EBM_ASSERT(std::isnan(splittingScoreNew1) || FloatEbmType { 0 } <= splittingScoreNew1); splittingScore += splittingScoreNew1; size_t cutSecond2HighBest; HistogramBucket<bClassification> * pTotals1HighLowBestInner = GetHistogramBucketByIndex<bClassification>(cBytesPerHistogramBucket, pAuxiliaryBucketZone, 20); HistogramBucket<bClassification> * pTotals1HighHighBestInner = GetHistogramBucketByIndex<bClassification>(cBytesPerHistogramBucket, pAuxiliaryBucketZone, 21); const FloatEbmType splittingScoreNew2 = SweepMultiDiemensional<compilerLearningTypeOrCountTargetClasses>( aHistogramBuckets, pFeatureGroup, aiStart, 0x2, 0, cSamplesRequiredForChildSplitMin, runtimeLearningTypeOrCountTargetClasses, pTotals1HighLowBestInner, &cutSecond2HighBest #ifndef NDEBUG , aHistogramBucketsDebugCopy , aHistogramBucketsEndDebug #endif // NDEBUG ); // if we get a NaN result, we'd like to propagate it by making bestSplit NaN. The rules for NaN values say that non equality comparisons are // all false so, let's flip this comparison such that it should be true for NaN values. If the compiler violates NaN comparions rules, // no big deal. NaN values will get us soon and shut down boosting. if(LIKELY(/* DO NOT CHANGE THIS WITHOUT READING THE ABOVE. WE DO THIS STRANGE COMPARISON FOR NaN values*/ !(k_illegalGain == splittingScoreNew2))) { EBM_ASSERT(std::isnan(splittingScoreNew2) || FloatEbmType { 0 } <= splittingScoreNew2); splittingScore += splittingScoreNew2; // if we get a NaN result, we'd like to propagate it by making bestSplit NaN. The rules for NaN values say that non equality comparisons // are all false so, let's flip this comparison such that it should be true for NaN values. If the compiler violates NaN comparions rules, // no big deal. NaN values will get us soon and shut down boosting. if(UNLIKELY(/* DO NOT CHANGE THIS WITHOUT READING THE ABOVE. WE DO THIS STRANGE COMPARISON FOR NaN values*/ !(splittingScore <= bestSplittingScore))) { bestSplittingScore = splittingScore; cutFirst2Best = iBin2; cutFirst2LowBest = cutSecond2LowBest; cutFirst2HighBest = cutSecond2HighBest; pTotals2LowLowBest->Copy(*pTotals1LowLowBestInner, cVectorLength); pTotals2LowHighBest->Copy(*pTotals1LowHighBestInner, cVectorLength); pTotals2HighLowBest->Copy(*pTotals1HighLowBestInner, cVectorLength); pTotals2HighHighBest->Copy(*pTotals1HighHighBestInner, cVectorLength); bCutFirst2 = true; } else { EBM_ASSERT(!std::isnan(splittingScore)); } } else { EBM_ASSERT(!std::isnan(splittingScoreNew2)); EBM_ASSERT(k_illegalGain == splittingScoreNew2); } } else { EBM_ASSERT(!std::isnan(splittingScoreNew1)); EBM_ASSERT(k_illegalGain == splittingScoreNew1); } ++iBin2; } while(iBin2 < cBinsDimension2 - 1); LOG_0(TraceLevelVerbose, "BoostMultiDimensional Done sweep loops"); FloatEbmType gain; // if we get a NaN result for bestSplittingScore, we might as well do less work and just create a zero split update right now. The rules // for NaN values say that non equality comparisons are all false so, let's flip this comparison such that it should be true for NaN values. // If the compiler violates NaN comparions rules, no big deal. NaN values will get us soon and shut down boosting. if(UNLIKELY(/* DO NOT CHANGE THIS WITHOUT READING THE ABOVE. WE DO THIS STRANGE COMPARISON FOR NaN values*/ !(k_illegalGain != bestSplittingScore))) { // there were no good cuts found, or we hit a NaN value #ifndef NDEBUG const bool bSetCountDivisions0 = #endif // NDEBUG pSmallChangeToModelOverwriteSingleSamplingSet->SetCountDivisions(0, 0); // we can't fail since we're setting this to zero, so no allocations. We don't in fact need the division array at all EBM_ASSERT(!bSetCountDivisions0); #ifndef NDEBUG const bool bSetCountDivisions1 = #endif // NDEBUG pSmallChangeToModelOverwriteSingleSamplingSet->SetCountDivisions(1, 0); // we can't fail since we're setting this to zero, so no allocations. We don't in fact need the division array at all EBM_ASSERT(!bSetCountDivisions1); // we don't need to call pSmallChangeToModelOverwriteSingleSamplingSet->EnsureValueCapacity, // since our value capacity would be 1, which is pre-allocated for(size_t iVector = 0; iVector < cVectorLength; ++iVector) { FloatEbmType prediction; if(bClassification) { prediction = EbmStatistics::ComputeSmallChangeForOneSegmentClassificationLogOdds( pHistogramBucketVectorEntryTotal[iVector].m_sumResidualError, pHistogramBucketVectorEntryTotal[iVector].GetSumDenominator() ); } else { EBM_ASSERT(IsRegression(compilerLearningTypeOrCountTargetClasses)); prediction = EbmStatistics::ComputeSmallChangeForOneSegmentRegression( pHistogramBucketVectorEntryTotal[iVector].m_sumResidualError, cSamplesInParentBucket ); } pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[iVector] = prediction; } gain = FloatEbmType { 0 }; // no splits means no gain } else { EBM_ASSERT(!std::isnan(bestSplittingScore)); EBM_ASSERT(k_illegalGain != bestSplittingScore); if(bCutFirst2) { // if bCutFirst2 is true, then there definetly was a cut, so we don't have to check for zero cuts if(pSmallChangeToModelOverwriteSingleSamplingSet->SetCountDivisions(1, 1)) { LOG_0(TraceLevelWarning, "WARNING BoostMultiDimensional pSmallChangeToModelOverwriteSingleSamplingSet->SetCountDivisions(1, 1)"); return true; } pSmallChangeToModelOverwriteSingleSamplingSet->GetDivisionPointer(1)[0] = cutFirst2Best; if(cutFirst2LowBest < cutFirst2HighBest) { if(pSmallChangeToModelOverwriteSingleSamplingSet->EnsureValueCapacity(cVectorLength * 6)) { LOG_0( TraceLevelWarning, "WARNING BoostMultiDimensional pSmallChangeToModelOverwriteSingleSamplingSet->EnsureValueCapacity(cVectorLength * 6)" ); return true; } if(pSmallChangeToModelOverwriteSingleSamplingSet->SetCountDivisions(0, 2)) { LOG_0(TraceLevelWarning, "WARNING BoostMultiDimensional pSmallChangeToModelOverwriteSingleSamplingSet->SetCountDivisions(0, 2)"); return true; } pSmallChangeToModelOverwriteSingleSamplingSet->GetDivisionPointer(0)[0] = cutFirst2LowBest; pSmallChangeToModelOverwriteSingleSamplingSet->GetDivisionPointer(0)[1] = cutFirst2HighBest; } else if(cutFirst2HighBest < cutFirst2LowBest) { if(pSmallChangeToModelOverwriteSingleSamplingSet->EnsureValueCapacity(cVectorLength * 6)) { LOG_0( TraceLevelWarning, "WARNING BoostMultiDimensional pSmallChangeToModelOverwriteSingleSamplingSet->EnsureValueCapacity(cVectorLength * 6)" ); return true; } if(pSmallChangeToModelOverwriteSingleSamplingSet->SetCountDivisions(0, 2)) { LOG_0(TraceLevelWarning, "WARNING BoostMultiDimensional pSmallChangeToModelOverwriteSingleSamplingSet->SetCountDivisions(0, 2)"); return true; } pSmallChangeToModelOverwriteSingleSamplingSet->GetDivisionPointer(0)[0] = cutFirst2HighBest; pSmallChangeToModelOverwriteSingleSamplingSet->GetDivisionPointer(0)[1] = cutFirst2LowBest; } else { if(pSmallChangeToModelOverwriteSingleSamplingSet->SetCountDivisions(0, 1)) { LOG_0(TraceLevelWarning, "WARNING BoostMultiDimensional pSmallChangeToModelOverwriteSingleSamplingSet->SetCountDivisions(0, 1)"); return true; } if(pSmallChangeToModelOverwriteSingleSamplingSet->EnsureValueCapacity(cVectorLength * 4)) { LOG_0( TraceLevelWarning, "WARNING BoostMultiDimensional pSmallChangeToModelOverwriteSingleSamplingSet->EnsureValueCapacity(cVectorLength * 4)" ); return true; } pSmallChangeToModelOverwriteSingleSamplingSet->GetDivisionPointer(0)[0] = cutFirst2LowBest; } HistogramBucketVectorEntry<bClassification> * const pHistogramBucketVectorEntryTotals2LowLowBest = pTotals2LowLowBest->GetHistogramBucketVectorEntry(); HistogramBucketVectorEntry<bClassification> * const pHistogramBucketVectorEntryTotals2LowHighBest = pTotals2LowHighBest->GetHistogramBucketVectorEntry(); HistogramBucketVectorEntry<bClassification> * const pHistogramBucketVectorEntryTotals2HighLowBest = pTotals2HighLowBest->GetHistogramBucketVectorEntry(); HistogramBucketVectorEntry<bClassification> * const pHistogramBucketVectorEntryTotals2HighHighBest = pTotals2HighHighBest->GetHistogramBucketVectorEntry(); for(size_t iVector = 0; iVector < cVectorLength; ++iVector) { FloatEbmType predictionLowLow; FloatEbmType predictionLowHigh; FloatEbmType predictionHighLow; FloatEbmType predictionHighHigh; if(bClassification) { predictionLowLow = EbmStatistics::ComputeSmallChangeForOneSegmentClassificationLogOdds( pHistogramBucketVectorEntryTotals2LowLowBest[iVector].m_sumResidualError, pHistogramBucketVectorEntryTotals2LowLowBest[iVector].GetSumDenominator() ); predictionLowHigh = EbmStatistics::ComputeSmallChangeForOneSegmentClassificationLogOdds( pHistogramBucketVectorEntryTotals2LowHighBest[iVector].m_sumResidualError, pHistogramBucketVectorEntryTotals2LowHighBest[iVector].GetSumDenominator() ); predictionHighLow = EbmStatistics::ComputeSmallChangeForOneSegmentClassificationLogOdds( pHistogramBucketVectorEntryTotals2HighLowBest[iVector].m_sumResidualError, pHistogramBucketVectorEntryTotals2HighLowBest[iVector].GetSumDenominator() ); predictionHighHigh = EbmStatistics::ComputeSmallChangeForOneSegmentClassificationLogOdds( pHistogramBucketVectorEntryTotals2HighHighBest[iVector].m_sumResidualError, pHistogramBucketVectorEntryTotals2HighHighBest[iVector].GetSumDenominator() ); } else { EBM_ASSERT(IsRegression(compilerLearningTypeOrCountTargetClasses)); predictionLowLow = EbmStatistics::ComputeSmallChangeForOneSegmentRegression( pHistogramBucketVectorEntryTotals2LowLowBest[iVector].m_sumResidualError, static_cast<FloatEbmType>(pTotals2LowLowBest->GetCountSamplesInBucket()) ); predictionLowHigh = EbmStatistics::ComputeSmallChangeForOneSegmentRegression( pHistogramBucketVectorEntryTotals2LowHighBest[iVector].m_sumResidualError, static_cast<FloatEbmType>(pTotals2LowHighBest->GetCountSamplesInBucket()) ); predictionHighLow = EbmStatistics::ComputeSmallChangeForOneSegmentRegression( pHistogramBucketVectorEntryTotals2HighLowBest[iVector].m_sumResidualError, static_cast<FloatEbmType>(pTotals2HighLowBest->GetCountSamplesInBucket()) ); predictionHighHigh = EbmStatistics::ComputeSmallChangeForOneSegmentRegression( pHistogramBucketVectorEntryTotals2HighHighBest[iVector].m_sumResidualError, static_cast<FloatEbmType>(pTotals2HighHighBest->GetCountSamplesInBucket()) ); } if(cutFirst2LowBest < cutFirst2HighBest) { pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[0 * cVectorLength + iVector] = predictionLowLow; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[1 * cVectorLength + iVector] = predictionLowHigh; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[2 * cVectorLength + iVector] = predictionLowHigh; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[3 * cVectorLength + iVector] = predictionHighLow; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[4 * cVectorLength + iVector] = predictionHighLow; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[5 * cVectorLength + iVector] = predictionHighHigh; } else if(cutFirst2HighBest < cutFirst2LowBest) { pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[0 * cVectorLength + iVector] = predictionLowLow; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[1 * cVectorLength + iVector] = predictionLowLow; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[2 * cVectorLength + iVector] = predictionLowHigh; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[3 * cVectorLength + iVector] = predictionHighLow; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[4 * cVectorLength + iVector] = predictionHighHigh; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[5 * cVectorLength + iVector] = predictionHighHigh; } else { pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[0 * cVectorLength + iVector] = predictionLowLow; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[1 * cVectorLength + iVector] = predictionLowHigh; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[2 * cVectorLength + iVector] = predictionHighLow; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[3 * cVectorLength + iVector] = predictionHighHigh; } } } else { if(pSmallChangeToModelOverwriteSingleSamplingSet->SetCountDivisions(0, 1)) { LOG_0(TraceLevelWarning, "WARNING BoostMultiDimensional pSmallChangeToModelOverwriteSingleSamplingSet->SetCountDivisions(0, 1)"); return true; } pSmallChangeToModelOverwriteSingleSamplingSet->GetDivisionPointer(0)[0] = cutFirst1Best; if(cutFirst1LowBest < cutFirst1HighBest) { if(pSmallChangeToModelOverwriteSingleSamplingSet->EnsureValueCapacity(cVectorLength * 6)) { LOG_0( TraceLevelWarning, "WARNING BoostMultiDimensional pSmallChangeToModelOverwriteSingleSamplingSet->EnsureValueCapacity(cVectorLength * 6)" ); return true; } if(pSmallChangeToModelOverwriteSingleSamplingSet->SetCountDivisions(1, 2)) { LOG_0(TraceLevelWarning, "WARNING BoostMultiDimensional pSmallChangeToModelOverwriteSingleSamplingSet->SetCountDivisions(1, 2)"); return true; } pSmallChangeToModelOverwriteSingleSamplingSet->GetDivisionPointer(1)[0] = cutFirst1LowBest; pSmallChangeToModelOverwriteSingleSamplingSet->GetDivisionPointer(1)[1] = cutFirst1HighBest; } else if(cutFirst1HighBest < cutFirst1LowBest) { if(pSmallChangeToModelOverwriteSingleSamplingSet->EnsureValueCapacity(cVectorLength * 6)) { LOG_0( TraceLevelWarning, "WARNING BoostMultiDimensional pSmallChangeToModelOverwriteSingleSamplingSet->EnsureValueCapacity(cVectorLength * 6)" ); return true; } if(pSmallChangeToModelOverwriteSingleSamplingSet->SetCountDivisions(1, 2)) { LOG_0(TraceLevelWarning, "WARNING BoostMultiDimensional pSmallChangeToModelOverwriteSingleSamplingSet->SetCountDivisions(1, 2)"); return true; } pSmallChangeToModelOverwriteSingleSamplingSet->GetDivisionPointer(1)[0] = cutFirst1HighBest; pSmallChangeToModelOverwriteSingleSamplingSet->GetDivisionPointer(1)[1] = cutFirst1LowBest; } else { if(pSmallChangeToModelOverwriteSingleSamplingSet->SetCountDivisions(1, 1)) { LOG_0(TraceLevelWarning, "WARNING BoostMultiDimensional pSmallChangeToModelOverwriteSingleSamplingSet->SetCountDivisions(1, 1)"); return true; } if(pSmallChangeToModelOverwriteSingleSamplingSet->EnsureValueCapacity(cVectorLength * 4)) { LOG_0( TraceLevelWarning, "WARNING BoostMultiDimensional pSmallChangeToModelOverwriteSingleSamplingSet->EnsureValueCapacity(cVectorLength * 4)" ); return true; } pSmallChangeToModelOverwriteSingleSamplingSet->GetDivisionPointer(1)[0] = cutFirst1LowBest; } HistogramBucketVectorEntry<bClassification> * const pHistogramBucketVectorEntryTotals1LowLowBest = pTotals1LowLowBest->GetHistogramBucketVectorEntry(); HistogramBucketVectorEntry<bClassification> * const pHistogramBucketVectorEntryTotals1LowHighBest = pTotals1LowHighBest->GetHistogramBucketVectorEntry(); HistogramBucketVectorEntry<bClassification> * const pHistogramBucketVectorEntryTotals1HighLowBest = pTotals1HighLowBest->GetHistogramBucketVectorEntry(); HistogramBucketVectorEntry<bClassification> * const pHistogramBucketVectorEntryTotals1HighHighBest = pTotals1HighHighBest->GetHistogramBucketVectorEntry(); for(size_t iVector = 0; iVector < cVectorLength; ++iVector) { FloatEbmType predictionLowLow; FloatEbmType predictionLowHigh; FloatEbmType predictionHighLow; FloatEbmType predictionHighHigh; if(bClassification) { predictionLowLow = EbmStatistics::ComputeSmallChangeForOneSegmentClassificationLogOdds( pHistogramBucketVectorEntryTotals1LowLowBest[iVector].m_sumResidualError, pHistogramBucketVectorEntryTotals1LowLowBest[iVector].GetSumDenominator() ); predictionLowHigh = EbmStatistics::ComputeSmallChangeForOneSegmentClassificationLogOdds( pHistogramBucketVectorEntryTotals1LowHighBest[iVector].m_sumResidualError, pHistogramBucketVectorEntryTotals1LowHighBest[iVector].GetSumDenominator() ); predictionHighLow = EbmStatistics::ComputeSmallChangeForOneSegmentClassificationLogOdds( pHistogramBucketVectorEntryTotals1HighLowBest[iVector].m_sumResidualError, pHistogramBucketVectorEntryTotals1HighLowBest[iVector].GetSumDenominator() ); predictionHighHigh = EbmStatistics::ComputeSmallChangeForOneSegmentClassificationLogOdds( pHistogramBucketVectorEntryTotals1HighHighBest[iVector].m_sumResidualError, pHistogramBucketVectorEntryTotals1HighHighBest[iVector].GetSumDenominator() ); } else { EBM_ASSERT(IsRegression(compilerLearningTypeOrCountTargetClasses)); predictionLowLow = EbmStatistics::ComputeSmallChangeForOneSegmentRegression( pHistogramBucketVectorEntryTotals1LowLowBest[iVector].m_sumResidualError, static_cast<FloatEbmType>(pTotals1LowLowBest->GetCountSamplesInBucket()) ); predictionLowHigh = EbmStatistics::ComputeSmallChangeForOneSegmentRegression( pHistogramBucketVectorEntryTotals1LowHighBest[iVector].m_sumResidualError, static_cast<FloatEbmType>(pTotals1LowHighBest->GetCountSamplesInBucket()) ); predictionHighLow = EbmStatistics::ComputeSmallChangeForOneSegmentRegression( pHistogramBucketVectorEntryTotals1HighLowBest[iVector].m_sumResidualError, static_cast<FloatEbmType>(pTotals1HighLowBest->GetCountSamplesInBucket()) ); predictionHighHigh = EbmStatistics::ComputeSmallChangeForOneSegmentRegression( pHistogramBucketVectorEntryTotals1HighHighBest[iVector].m_sumResidualError, static_cast<FloatEbmType>(pTotals1HighHighBest->GetCountSamplesInBucket()) ); } if(cutFirst1LowBest < cutFirst1HighBest) { pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[0 * cVectorLength + iVector] = predictionLowLow; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[1 * cVectorLength + iVector] = predictionHighLow; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[2 * cVectorLength + iVector] = predictionLowHigh; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[3 * cVectorLength + iVector] = predictionHighLow; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[4 * cVectorLength + iVector] = predictionLowHigh; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[5 * cVectorLength + iVector] = predictionHighHigh; } else if(cutFirst1HighBest < cutFirst1LowBest) { pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[0 * cVectorLength + iVector] = predictionLowLow; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[1 * cVectorLength + iVector] = predictionHighLow; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[2 * cVectorLength + iVector] = predictionLowLow; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[3 * cVectorLength + iVector] = predictionHighHigh; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[4 * cVectorLength + iVector] = predictionLowHigh; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[5 * cVectorLength + iVector] = predictionHighHigh; } else { pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[0 * cVectorLength + iVector] = predictionLowLow; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[1 * cVectorLength + iVector] = predictionHighLow; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[2 * cVectorLength + iVector] = predictionLowHigh; pSmallChangeToModelOverwriteSingleSamplingSet->GetValuePointer()[3 * cVectorLength + iVector] = predictionHighHigh; } } } // for regression, bestSplittingScore and splittingScoreParent can be infinity. There is a super-super-super-rare case where we can have // splittingScoreParent overflow to +infinity due to numeric issues, but not bestSplittingScore, and then the subtration causes the result // to be -infinity. The universe will probably die of heat death before we get a -infinity value, but perhaps an adversarial dataset could // trigger it, and we don't want someone giving us data to use a vulnerability in our system, so check for it! gain = bestSplittingScore - splittingScoreParent; } // TODO: this gain value is untested. We should build a new test that compares the single feature gains to the multi-dimensional gains by // making a pair where one of the dimensions duplicates values in the 0 and 1 bin. Then the gain should be identical, if there is only 1 split allowed *pTotalGain = gain; return false; } WARNING_POP }; template<ptrdiff_t compilerLearningTypeOrCountTargetClassesPossible> class FindBestBoostingSplitPairsTarget final { public: FindBestBoostingSplitPairsTarget() = delete; // this is a static class. Do not construct INLINE_ALWAYS static bool Func( EbmBoostingState * const pEbmBoostingState, const FeatureGroup * const pFeatureGroup, const size_t cSamplesRequiredForChildSplitMin, HistogramBucketBase * pAuxiliaryBucketZone, HistogramBucketBase * const pTotal, HistogramBucketBase * const aHistogramBuckets, SegmentedTensor * const pSmallChangeToModelOverwriteSingleSamplingSet, FloatEbmType * const pTotalGain #ifndef NDEBUG , const HistogramBucketBase * const aHistogramBucketsDebugCopy , const unsigned char * const aHistogramBucketsEndDebug #endif // NDEBUG ) { static_assert(IsClassification(compilerLearningTypeOrCountTargetClassesPossible), "compilerLearningTypeOrCountTargetClassesPossible needs to be a classification"); static_assert(compilerLearningTypeOrCountTargetClassesPossible <= k_cCompilerOptimizedTargetClassesMax, "We can't have this many items in a data pack."); const ptrdiff_t runtimeLearningTypeOrCountTargetClasses = pEbmBoostingState->GetRuntimeLearningTypeOrCountTargetClasses(); EBM_ASSERT(IsClassification(runtimeLearningTypeOrCountTargetClasses)); EBM_ASSERT(runtimeLearningTypeOrCountTargetClasses <= k_cCompilerOptimizedTargetClassesMax); if(compilerLearningTypeOrCountTargetClassesPossible == runtimeLearningTypeOrCountTargetClasses) { return FindBestBoostingSplitPairsInternal<compilerLearningTypeOrCountTargetClassesPossible>::Func( pEbmBoostingState, pFeatureGroup, cSamplesRequiredForChildSplitMin, pAuxiliaryBucketZone, pTotal, aHistogramBuckets, pSmallChangeToModelOverwriteSingleSamplingSet, pTotalGain #ifndef NDEBUG , aHistogramBucketsDebugCopy , aHistogramBucketsEndDebug #endif // NDEBUG ); } else { return FindBestBoostingSplitPairsTarget<compilerLearningTypeOrCountTargetClassesPossible + 1>::Func( pEbmBoostingState, pFeatureGroup, cSamplesRequiredForChildSplitMin, pAuxiliaryBucketZone, pTotal, aHistogramBuckets, pSmallChangeToModelOverwriteSingleSamplingSet, pTotalGain #ifndef NDEBUG , aHistogramBucketsDebugCopy , aHistogramBucketsEndDebug #endif // NDEBUG ); } } }; template<> class FindBestBoostingSplitPairsTarget<k_cCompilerOptimizedTargetClassesMax + 1> final { public: FindBestBoostingSplitPairsTarget() = delete; // this is a static class. Do not construct INLINE_ALWAYS static bool Func( EbmBoostingState * const pEbmBoostingState, const FeatureGroup * const pFeatureGroup, const size_t cSamplesRequiredForChildSplitMin, HistogramBucketBase * pAuxiliaryBucketZone, HistogramBucketBase * const pTotal, HistogramBucketBase * const aHistogramBuckets, SegmentedTensor * const pSmallChangeToModelOverwriteSingleSamplingSet, FloatEbmType * const pTotalGain #ifndef NDEBUG , const HistogramBucketBase * const aHistogramBucketsDebugCopy , const unsigned char * const aHistogramBucketsEndDebug #endif // NDEBUG ) { static_assert(IsClassification(k_cCompilerOptimizedTargetClassesMax), "k_cCompilerOptimizedTargetClassesMax needs to be a classification"); EBM_ASSERT(IsClassification(pEbmBoostingState->GetRuntimeLearningTypeOrCountTargetClasses())); EBM_ASSERT(k_cCompilerOptimizedTargetClassesMax < pEbmBoostingState->GetRuntimeLearningTypeOrCountTargetClasses()); return FindBestBoostingSplitPairsInternal<k_dynamicClassification>::Func( pEbmBoostingState, pFeatureGroup, cSamplesRequiredForChildSplitMin, pAuxiliaryBucketZone, pTotal, aHistogramBuckets, pSmallChangeToModelOverwriteSingleSamplingSet, pTotalGain #ifndef NDEBUG , aHistogramBucketsDebugCopy , aHistogramBucketsEndDebug #endif // NDEBUG ); } }; extern bool FindBestBoostingSplitPairs( EbmBoostingState * const pEbmBoostingState, const FeatureGroup * const pFeatureGroup, const size_t cSamplesRequiredForChildSplitMin, HistogramBucketBase * pAuxiliaryBucketZone, HistogramBucketBase * const pTotal, HistogramBucketBase * const aHistogramBuckets, SegmentedTensor * const pSmallChangeToModelOverwriteSingleSamplingSet, FloatEbmType * const pTotalGain #ifndef NDEBUG , const HistogramBucketBase * const aHistogramBucketsDebugCopy , const unsigned char * const aHistogramBucketsEndDebug #endif // NDEBUG ) { const ptrdiff_t runtimeLearningTypeOrCountTargetClasses = pEbmBoostingState->GetRuntimeLearningTypeOrCountTargetClasses(); if(IsClassification(runtimeLearningTypeOrCountTargetClasses)) { return FindBestBoostingSplitPairsTarget<2>::Func( pEbmBoostingState, pFeatureGroup, cSamplesRequiredForChildSplitMin, pAuxiliaryBucketZone, pTotal, aHistogramBuckets, pSmallChangeToModelOverwriteSingleSamplingSet, pTotalGain #ifndef NDEBUG , aHistogramBucketsDebugCopy , aHistogramBucketsEndDebug #endif // NDEBUG ); } else { EBM_ASSERT(IsRegression(runtimeLearningTypeOrCountTargetClasses)); return FindBestBoostingSplitPairsInternal<k_regression>::Func( pEbmBoostingState, pFeatureGroup, cSamplesRequiredForChildSplitMin, pAuxiliaryBucketZone, pTotal, aHistogramBuckets, pSmallChangeToModelOverwriteSingleSamplingSet, pTotalGain #ifndef NDEBUG , aHistogramBucketsDebugCopy , aHistogramBucketsEndDebug #endif // NDEBUG ); } }