1- import { ThunkAction as ReduxThunkAction , AnyAction } from '@reduxjs/toolkit' ;
1+ import { AnyAction , ThunkAction as ReduxThunkAction } from '@reduxjs/toolkit' ;
22
3+ import { addCrateType , editCode } from './reducers/code' ;
34import {
4- getCrateType ,
5- runAsTest ,
6- wasmLikelyToWork ,
7- } from './selectors' ;
5+ changeBacktrace ,
6+ changeChannel ,
7+ changeEditionRaw ,
8+ changeMode ,
9+ changePrimaryAction ,
10+ } from './reducers/configuration' ;
11+ import { performCompileToAssemblyOnly } from './reducers/output/assembly' ;
12+ import { performCommonExecute } from './reducers/output/execute' ;
13+ import { performGistLoad } from './reducers/output/gist' ;
14+ import { performCompileToHirOnly } from './reducers/output/hir' ;
15+ import { performCompileToLlvmIrOnly } from './reducers/output/llvmIr' ;
16+ import { performCompileToMirOnly } from './reducers/output/mir' ;
17+ import { performCompileToWasmOnly } from './reducers/output/wasm' ;
18+ import { navigateToHelp , navigateToIndex } from './reducers/page' ;
19+ import { getCrateType , runAsTest , wasmLikelyToWork } from './selectors' ;
820import State from './state' ;
921import {
1022 Backtrace ,
@@ -19,33 +31,15 @@ import {
1931 parseMode ,
2032} from './types' ;
2133
22- import { performCommonExecute } from './reducers/output/execute' ;
23- import { performGistLoad } from './reducers/output/gist' ;
24- import { performCompileToAssemblyOnly } from './reducers/output/assembly' ;
25- import { performCompileToHirOnly } from './reducers/output/hir' ;
26- import { performCompileToLlvmIrOnly } from './reducers/output/llvmIr' ;
27- import { performCompileToMirOnly } from './reducers/output/mir' ;
28- import { performCompileToWasmOnly } from './reducers/output/wasm' ;
29- import { navigateToHelp , navigateToIndex } from './reducers/page' ;
30- import { addCrateType , editCode } from './reducers/code' ;
31- import {
32- changeBacktrace ,
33- changeChannel ,
34- changeEditionRaw ,
35- changeMode ,
36- changePrimaryAction ,
37- } from './reducers/configuration' ;
38-
3934export type ThunkAction < T = void > = ReduxThunkAction < T , State , { } , AnyAction > ;
4035
41- export const reExecuteWithBacktrace = ( ) : ThunkAction => dispatch => {
36+ export const reExecuteWithBacktrace = ( ) : ThunkAction => ( dispatch ) => {
4237 dispatch ( changeBacktrace ( Backtrace . Enabled ) ) ;
4338 dispatch ( performExecuteOnly ( ) ) ;
4439} ;
4540
46-
4741function performAutoOnly ( ) : ThunkAction {
48- return function ( dispatch , getState ) {
42+ return function ( dispatch , getState ) {
4943 const state = getState ( ) ;
5044 const crateType = getCrateType ( state ) ;
5145 const tests = runAsTest ( state ) ;
@@ -62,7 +56,7 @@ const performTestOnly = (): ThunkAction => (dispatch, getState) => {
6256 return dispatch ( performCommonExecute ( crateType , true ) ) ;
6357} ;
6458
65- const performCompileToNightlyHirOnly = ( ) : ThunkAction => dispatch => {
59+ const performCompileToNightlyHirOnly = ( ) : ThunkAction => ( dispatch ) => {
6660 dispatch ( changeChannel ( Channel . Nightly ) ) ;
6761 dispatch ( performCompileToHirOnly ( ) ) ;
6862} ;
@@ -94,36 +88,56 @@ export const performPrimaryAction = (): ThunkAction => (dispatch, getState) => {
9488 dispatch ( primaryAction ( ) ) ;
9589} ;
9690
97- const performAndSwitchPrimaryAction = ( inner : ( ) => ThunkAction , id : PrimaryAction ) => ( ) : ThunkAction => dispatch => {
98- dispatch ( changePrimaryAction ( id ) ) ;
99- dispatch ( inner ( ) ) ;
100- } ;
91+ const performAndSwitchPrimaryAction =
92+ ( inner : ( ) => ThunkAction , id : PrimaryAction ) => ( ) : ThunkAction => ( dispatch ) => {
93+ dispatch ( changePrimaryAction ( id ) ) ;
94+ dispatch ( inner ( ) ) ;
95+ } ;
10196
102- export const performExecute =
103- performAndSwitchPrimaryAction ( performExecuteOnly , PrimaryActionCore . Execute ) ;
104- export const performCompile =
105- performAndSwitchPrimaryAction ( performCompileOnly , PrimaryActionCore . Compile ) ;
106- export const performTest =
107- performAndSwitchPrimaryAction ( performTestOnly , PrimaryActionCore . Test ) ;
108- export const performCompileToAssembly =
109- performAndSwitchPrimaryAction ( performCompileToAssemblyOnly , PrimaryActionCore . Asm ) ;
110- export const performCompileToLLVM =
111- performAndSwitchPrimaryAction ( performCompileToLlvmIrOnly , PrimaryActionCore . LlvmIr ) ;
112- export const performCompileToMir =
113- performAndSwitchPrimaryAction ( performCompileToMirOnly , PrimaryActionCore . Mir ) ;
114- export const performCompileToNightlyHir =
115- performAndSwitchPrimaryAction ( performCompileToNightlyHirOnly , PrimaryActionCore . Hir ) ;
116- export const performCompileToWasm =
117- performAndSwitchPrimaryAction ( performCompileToCdylibWasmOnly , PrimaryActionCore . Wasm ) ;
97+ export const performExecute = performAndSwitchPrimaryAction (
98+ performExecuteOnly ,
99+ PrimaryActionCore . Execute ,
100+ ) ;
101+ export const performCompile = performAndSwitchPrimaryAction (
102+ performCompileOnly ,
103+ PrimaryActionCore . Compile ,
104+ ) ;
105+ export const performTest = performAndSwitchPrimaryAction ( performTestOnly , PrimaryActionCore . Test ) ;
106+ export const performCompileToAssembly = performAndSwitchPrimaryAction (
107+ performCompileToAssemblyOnly ,
108+ PrimaryActionCore . Asm ,
109+ ) ;
110+ export const performCompileToLLVM = performAndSwitchPrimaryAction (
111+ performCompileToLlvmIrOnly ,
112+ PrimaryActionCore . LlvmIr ,
113+ ) ;
114+ export const performCompileToMir = performAndSwitchPrimaryAction (
115+ performCompileToMirOnly ,
116+ PrimaryActionCore . Mir ,
117+ ) ;
118+ export const performCompileToNightlyHir = performAndSwitchPrimaryAction (
119+ performCompileToNightlyHirOnly ,
120+ PrimaryActionCore . Hir ,
121+ ) ;
122+ export const performCompileToWasm = performAndSwitchPrimaryAction (
123+ performCompileToCdylibWasmOnly ,
124+ PrimaryActionCore . Wasm ,
125+ ) ;
118126
119127export function indexPageLoad ( {
120128 code,
121129 gist,
122130 version,
123131 mode : modeString ,
124132 edition : editionString ,
125- } : { code ?: string , gist ?: string , version ?: string , mode ?: string , edition ?: string } ) : ThunkAction {
126- return function ( dispatch ) {
133+ } : {
134+ code ?: string ;
135+ gist ?: string ;
136+ version ?: string ;
137+ mode ?: string ;
138+ edition ?: string ;
139+ } ) : ThunkAction {
140+ return function ( dispatch ) {
127141 const channel = parseChannel ( version ) || Channel . Stable ;
128142 const mode = parseMode ( modeString ) || Mode . Debug ;
129143 let maybeEdition = parseEdition ( editionString ) ;
@@ -156,7 +170,7 @@ export function indexPageLoad({
156170export const helpPageLoad = navigateToHelp ;
157171
158172export function showExample ( code : string ) : ThunkAction {
159- return function ( dispatch ) {
173+ return function ( dispatch ) {
160174 dispatch ( navigateToIndex ( ) ) ;
161175 dispatch ( editCode ( code ) ) ;
162176 } ;
0 commit comments