Skip to content

Commit

Permalink
vbs: let env.get report a missing symbol without raising an exception
Browse files Browse the repository at this point in the history
This change is not useful per se, but prepares DEBUG-EVAL.
  • Loading branch information
asarhaddon committed Oct 23, 2024
1 parent 38fbfb0 commit 82518e4
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 2 deletions.
7 changes: 5 additions & 2 deletions impls/vbs/env.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ Class Environment
If TypeName(objOuter) <> "Nothing" Then
Set varRet = objOuter.Find(varKey)
Else
Err.Raise vbObjectError, _
"Environment", "'" + varKey + "' not found"
Set varRet = Nothing
End If
End If

Expand All @@ -55,7 +54,11 @@ Class Environment
If objEnv Is objSelf Then
Set varRet = objBinds(varKey)
Else
If TypeName(objEnv) <> "Nothing" Then
Set varRet = objEnv.Get(varKey)
Else
Set varRet = Nothing
End If
End If

Set [Get] = varRet
Expand Down
4 changes: 4 additions & 0 deletions impls/vbs/step3_env.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ Function EvaluateAST(objCode, objEnv)
Select Case objCode.Type
Case TYPES.SYMBOL
Set varRet = objEnv.Get(objCode.Value)
if TypeName(varRet) = "Nothing" Then
Err.Raise vbObjectError, _
"EvaluateAST", "'" + objCode.Value + "' not found"
End If
Case TYPES.LIST
Err.Raise vbObjectError, _
"EvaluateAST", "Unexpect type."
Expand Down
4 changes: 4 additions & 0 deletions impls/vbs/step4_if_fn_do.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ Function EvaluateAST(objCode, objEnv)
Select Case objCode.Type
Case TYPES.SYMBOL
Set varRet = objEnv.Get(objCode.Value)
if TypeName(varRet) = "Nothing" Then
Err.Raise vbObjectError, _
"EvaluateAST", "'" + objCode.Value + "' not found"
End If
Case TYPES.LIST
Err.Raise vbObjectError, _
"EvaluateAST", "Unexpect type."
Expand Down
4 changes: 4 additions & 0 deletions impls/vbs/step5_tco.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ Function EvaluateAST(objCode, objEnv)
Select Case objCode.Type
Case TYPES.SYMBOL
Set varRet = objEnv.Get(objCode.Value)
if TypeName(varRet) = "Nothing" Then
Err.Raise vbObjectError, _
"EvaluateAST", "'" + objCode.Value + "' not found"
End If
Case TYPES.LIST
Err.Raise vbObjectError, _
"EvaluateAST", "Unexpect type."
Expand Down
4 changes: 4 additions & 0 deletions impls/vbs/step6_file.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ Function EvaluateAST(objCode, objEnv)
Select Case objCode.Type
Case TYPES.SYMBOL
Set varRet = objEnv.Get(objCode.Value)
if TypeName(varRet) = "Nothing" Then
Err.Raise vbObjectError, _
"EvaluateAST", "'" + objCode.Value + "' not found"
End If
Case TYPES.LIST
Err.Raise vbObjectError, _
"EvaluateAST", "Unexpect type."
Expand Down
4 changes: 4 additions & 0 deletions impls/vbs/step7_quote.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ Function EvaluateAST(objCode, objEnv)
Select Case objCode.Type
Case TYPES.SYMBOL
Set varRet = objEnv.Get(objCode.Value)
if TypeName(varRet) = "Nothing" Then
Err.Raise vbObjectError, _
"EvaluateAST", "'" + objCode.Value + "' not found"
End If
Case TYPES.LIST
Err.Raise vbObjectError, _
"EvaluateAST", "Unexpect type."
Expand Down
4 changes: 4 additions & 0 deletions impls/vbs/step8_macros.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ Function EvaluateAST(objCode, objEnv)
Select Case objCode.Type
Case TYPES.SYMBOL
Set varRet = objEnv.Get(objCode.Value)
if TypeName(varRet) = "Nothing" Then
Err.Raise vbObjectError, _
"EvaluateAST", "'" + objCode.Value + "' not found"
End If
Case TYPES.LIST
Err.Raise vbObjectError, _
"EvaluateAST", "Unexpect type."
Expand Down
4 changes: 4 additions & 0 deletions impls/vbs/step9_try.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,10 @@ Function EvaluateAST(objCode, objEnv)
Select Case objCode.Type
Case TYPES.SYMBOL
Set varRet = objEnv.Get(objCode.Value)
if TypeName(varRet) = "Nothing" Then
Err.Raise vbObjectError, _
"EvaluateAST", "'" + objCode.Value + "' not found"
End If
Case TYPES.LIST
Err.Raise vbObjectError, _
"EvaluateAST", "Unexpect type."
Expand Down
4 changes: 4 additions & 0 deletions impls/vbs/stepA_mal.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,10 @@ Function EvaluateAST(objCode, objEnv)
Select Case objCode.Type
Case TYPES.SYMBOL
Set varRet = objEnv.Get(objCode.Value)
if TypeName(varRet) = "Nothing" Then
Err.Raise vbObjectError, _
"EvaluateAST", "'" + objCode.Value + "' not found"
End If
Case TYPES.LIST
Err.Raise vbObjectError, _
"EvaluateAST", "Unexpect type."
Expand Down

0 comments on commit 82518e4

Please sign in to comment.