chore: Version 0.3 #136

Open
aniva wants to merge 487 commits from dev into main
1 changed files with 25 additions and 28 deletions
Showing only changes of commit e4d53733d0 - Show all commits

View File

@ -169,30 +169,28 @@ def execute (command: Protocol.Command): MainM Lean.Json := do
return .ok { tacticErrors? := .some messages } return .ok { tacticErrors? := .some messages }
goal_continue (args: Protocol.GoalContinue): MainM (CR Protocol.GoalContinueResult) := do goal_continue (args: Protocol.GoalContinue): MainM (CR Protocol.GoalContinueResult) := do
let state ← get let state ← get
match state.goalStates.find? args.target with let .some target := state.goalStates.find? args.target | return .error $ errorIndex s!"Invalid state index {args.target}"
| .none => return .error $ errorIndex s!"Invalid state index {args.target}" let nextState? ← match args.branch?, args.goals? with
| .some target => do | .some branchId, .none => do
let nextState? ← match args.branch?, args.goals? with match state.goalStates.find? branchId with
| .some branchId, .none => do | .none => return .error $ errorIndex s!"Invalid state index {branchId}"
match state.goalStates.find? branchId with | .some branch => pure $ goalContinue target branch
| .none => return .error $ errorIndex s!"Invalid state index {branchId}" | .none, .some goals =>
| .some branch => pure $ goalContinue target branch pure $ goalResume target goals
| .none, .some goals => | _, _ => return .error <| errorI "arguments" "Exactly one of {branch, goals} must be supplied"
pure $ goalResume target goals match nextState? with
| _, _ => return .error <| errorI "arguments" "Exactly one of {branch, goals} must be supplied" | .error error => return .error <| errorI "structure" error
match nextState? with | .ok nextGoalState =>
| .error error => return .error <| errorI "structure" error let nextStateId := state.nextId
| .ok nextGoalState => set { state with
let nextStateId := state.nextId goalStates := state.goalStates.insert nextStateId nextGoalState,
set { state with nextId := state.nextId + 1
goalStates := state.goalStates.insert nextStateId nextGoalState, }
nextId := state.nextId + 1 let goals ← goalSerialize nextGoalState (options := state.options)
} return .ok {
let goals ← goalSerialize nextGoalState (options := state.options) nextStateId,
return .ok { goals,
nextStateId, }
goals,
}
goal_delete (args: Protocol.GoalDelete): MainM (CR Protocol.GoalDeleteResult) := do goal_delete (args: Protocol.GoalDelete): MainM (CR Protocol.GoalDeleteResult) := do
let state ← get let state ← get
let goalStates := args.stateIds.foldl (λ map id => map.erase id) state.goalStates let goalStates := args.stateIds.foldl (λ map id => map.erase id) state.goalStates
@ -200,10 +198,9 @@ def execute (command: Protocol.Command): MainM Lean.Json := do
return .ok {} return .ok {}
goal_print (args: Protocol.GoalPrint): MainM (CR Protocol.GoalPrintResult) := do goal_print (args: Protocol.GoalPrint): MainM (CR Protocol.GoalPrintResult) := do
let state ← get let state ← get
match state.goalStates.find? args.stateId with let .some goalState := state.goalStates.find? args.stateId | return .error $ errorIndex s!"Invalid state index {args.stateId}"
| .none => return .error $ errorIndex s!"Invalid state index {args.stateId}" let result ← runMetaInMainM <| goalPrint goalState state.options
| .some goalState => runMetaM <| do return .ok result
return .ok (← goalPrint goalState state.options)
compile_unit (args: Protocol.CompileUnit): MainM (CR Protocol.CompileUnitResult) := do compile_unit (args: Protocol.CompileUnit): MainM (CR Protocol.CompileUnitResult) := do
let module := args.module.toName let module := args.module.toName
try try