Skip to content

Commit

Permalink
no-op commentary/thinking
Browse files Browse the repository at this point in the history
  • Loading branch information
StachuDotNet committed Jul 31, 2024
1 parent d2396d6 commit 8a3496c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,25 +347,6 @@ let rec eval (state : ExecutionState) (e : Instructions) : DvalTask =

uply {
match e with
| EUnit _ -> return DUnit

| EBool(_, b) -> return DBool b

// | EInt8(_, i) -> return DInt8 i
// | EUInt8(_, i) -> return DUInt8 i
// | EInt16(_, i) -> return DInt16 i
// | EUInt16(_, i) -> return DUInt16 i
// | EInt32(_, i) -> return DInt32 i
// | EUInt32(_, i) -> return DUInt32 i
| EInt64(_, i) -> return DInt64 i
// | EUInt64(_, i) -> return DUInt64 i
// | EInt128(_, i) -> return DInt128 i
// | EUInt128(_, i) -> return DUInt128 i

// | EFloat(_, value) -> return DFloat value

// | EChar(_, s) -> return DChar s

| EString(_, [ StringText s ]) ->
// We expect strings to be normalized during parsing
return DString(s)
Expand Down Expand Up @@ -413,21 +394,12 @@ let rec eval (state : ExecutionState) (e : Instructions) : DvalTask =

// return! eval { state with symbolTable = newSymtable } body

// | EList(_, exprs) ->
// let! results = Ply.List.mapSequentially (eval state) exprs
// return TypeChecker.DvalCreator.list callStack VT.unknown results

// | ETuple(_, first, second, theRest) ->
// let! firstResult = eval state first
// let! secondResult = eval state second
// let! otherResults = Ply.List.mapSequentially (eval state) theRest
// return DTuple(firstResult, secondResult, otherResults)

// | EVariable(_, name) ->
// match Map.find name state.symbolTable with
// | None -> return errStr callStack $"There is no variable named: {name}"
// | Some other -> return other


// | ERecord(_, typeName, fields) ->
// let types = ExecutionState.availableTypes state
Expand Down
22 changes: 18 additions & 4 deletions backend/src/LibExecution/Interpreter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,14 @@ let rec execute

// later, `x`
| GetVar(loadTo, varName) ->
let value = Map.find varName vmState.variables |> Option.defaultValue DUnit // TODO
let value =
Map.find varName vmState.variables
// TODO: handle missing variable
//return errStr callStack $"There is no variable named: {name}"
|> Option.defaultValue DUnit

vmState.registers[loadTo] <- value

return! execute state vmState instructions resultReg (counter + 1)


Expand All @@ -70,6 +76,11 @@ let rec execute
match vmState.registers[listReg] with
| DList(vt, list) ->
// TODO: type checking of item-add; adjust vt

// Had:
// let! results = Ply.List.mapSequentially (eval state) exprs
// return TypeChecker.DvalCreator.list callStack VT.unknown results

let itemToAdd = vmState.registers[itemToAddReg]
vmState.registers[listReg] <- DList(vt, list @ [ itemToAdd ])
return! execute state vmState instructions resultReg (counter + 1)
Expand Down Expand Up @@ -224,7 +235,8 @@ and execFn
return result
}

| PackageFunction(_id, _body) ->
| PackageFunction(_id, _instructionsWithContext) ->
//let _registersNeeded, instructions, resultReg = _instructionsWithContext
// // maybe this should instead be something like `state.tracing.tracePackageFnCall tlid`?
// // and the `caller` would be updated by that function? (maybe `caller` is a read-only thing.)
// let executionPoint = ExecutionPoint.Function(FQFnName.Package id)
Expand All @@ -235,7 +247,9 @@ and execFn
// // { state with
// // tracing.callStack.lastCalled = (executionPoint, Some(Expr.toID body)) }

// eval state body
// and how can we pass the args in?
// maybe fns need some LoadVal instructions frontloaded or something? hmm.
//eval state instructions resultReg
Ply DUnit // TODO

match! TypeChecker.checkFunctionReturnType types typeSymbolTable fn result with
Expand All @@ -245,7 +259,7 @@ and execFn



let rec eval
and eval
(state : ExecutionState)
(instructions : Instructions)
(resultReg : Register)
Expand Down

0 comments on commit 8a3496c

Please sign in to comment.