@@ -85,6 +85,7 @@ import org.usvm.UExpr
8585import org.usvm.UHeapRef
8686import org.usvm.USort
8787import org.usvm.api.allocateArray
88+ import org.usvm.api.evalTypeEquals
8889import org.usvm.dataflow.ts.infer.tryGetKnownType
8990import org.usvm.dataflow.ts.util.type
9091import org.usvm.isTrue
@@ -275,17 +276,39 @@ class TsExprResolver(
275276 return mkStringConstant(" boolean" , scope)
276277 }
277278 if (arg.sort == addressSort) {
279+ // val ref = arg.asExpr(addressSort)
280+ // if (ref == mkTsNullValue()) {
281+ // return mkStringConstant("object", scope)
282+ // } else if (ref == mkUndefinedValue()) {
283+ // return mkStringConstant("undefined", scope)
284+ // }
285+ // val isStringLValue = mkFieldLValue(boolSort, ref, "_isString")
286+ // if (scope.calcOnState { memory.read(isStringLValue) }.isTrue) {
287+ // return mkStringConstant("string", scope)
288+ // }
289+ // return mkStringConstant("object", scope)
290+
278291 val ref = arg.asExpr(addressSort)
279- if (ref == mkTsNullValue()) {
280- return mkStringConstant(" object" , scope)
281- } else if (ref == mkUndefinedValue()) {
282- return mkStringConstant(" undefined" , scope)
283- }
284- val isStringLValue = mkFieldLValue(boolSort, ref, " _isString" )
285- if (scope.calcOnState { memory.read(isStringLValue) }.isTrue) {
286- return mkStringConstant(" string" , scope)
287- }
288- return mkStringConstant(" object" , scope)
292+ // if (ref == mkTsNullValue()) {
293+ // return mkStringConstant("object", scope)
294+ // }
295+ // if (ref == mkUndefinedValue()) {
296+ // return mkStringConstant("undefined", scope)
297+ // }
298+ return mkIte(
299+ condition = mkHeapRefEq(ref, mkTsNullValue()),
300+ trueBranch = mkStringConstant(" object" , scope),
301+ falseBranch = mkIte(
302+ condition = mkHeapRefEq(ref, mkUndefinedValue()),
303+ trueBranch = mkStringConstant(" undefined" , scope),
304+ falseBranch = mkIte(
305+ // condition = scope.calcOnState { memory.read( mkFieldLValue(boolSort, ref, "_isString"))},
306+ condition = scope.calcOnState { memory.types.evalTypeEquals(ref, EtsStringType ) },
307+ trueBranch = mkStringConstant(" string" , scope),
308+ falseBranch = mkStringConstant(" object" , scope),
309+ )
310+ )
311+ )
289312 }
290313
291314 logger.warn { " visit(${expr::class .simpleName} ) is not implemented yet" }
0 commit comments