diff --git a/Sources/Fuzzilli/CodeGen/CodeGeneratorWeights.swift b/Sources/Fuzzilli/CodeGen/CodeGeneratorWeights.swift index 8699e2cc2b8bb16bd144dd284b1201ec9022b683..d06e80a215d1cda9a732f7b5f0a1bb97ef76ef65 100644 --- a/Sources/Fuzzilli/CodeGen/CodeGeneratorWeights.swift +++ b/Sources/Fuzzilli/CodeGen/CodeGeneratorWeights.swift @@ -30,6 +30,7 @@ public let codeGeneratorWeights = [ "IntArrayGenerator": 10, "TypedArrayGenerator": 20, "BuiltinObjectInstanceGenerator": 10, + "ArkTsMapObjectInstanceGnenrator": 5, "ObjectBuilderFunctionGenerator": 10, "ObjectConstructorGenerator": 10, "ClassDefinitionGenerator": 20, diff --git a/Sources/Fuzzilli/CodeGen/CodeGenerators.swift b/Sources/Fuzzilli/CodeGen/CodeGenerators.swift index c7d6970ac54b91175daf1862391f4a281c1566ad..3b502930d5532d13148c20bd115843efa0b6bd74 100644 --- a/Sources/Fuzzilli/CodeGen/CodeGenerators.swift +++ b/Sources/Fuzzilli/CodeGen/CodeGenerators.swift @@ -110,6 +110,12 @@ public let CodeGenerators: [CodeGenerator] = [ } }, + ValueGenerator("ArkTsMapObjectInstanceGnenrator") { b, n in + let builtin = "ArkTsMap" + let constructor = b.loadBuiltin(builtin) + b.construct(constructor) + }, + ValueGenerator("TypedArrayGenerator") { b, n in for _ in 0.. .jsMap) + /// Type of the ArkTs Map constructor builtin. + static let collectionsMapConstructor = JSType.constructor([.object()] => .collectionsMap) + /// Type of the JavaScript WeakMap constructor builtin. static let jsWeakMapConstructor = ILType.constructor([.object()] => .jsWeakMap) @@ -920,6 +928,26 @@ public extension ObjectGroup { ] ) + ///ObjectGroup modelling ArkTs Map objects + static let collectionsMaps = ObjectGroup( + name: "ArkTsMap", + instanceType: .collectionsMap, + properties: [ + "size" : .integer + ], + methods: [ + "entries" : [] => .object(), + "keys" : [] => .object(), + "values" : [] => .object(), + "clear" : [] => .undefined, + "delete" : [.anything] => .boolean, + "forEach" : [.function(), .opt(.object())] => .undefined, + "get" : [.anything] => .anything, + "has" : [.anything] => .boolean, + "set" : [.anything, .anything] => .collectionsMap, + ] + ) + /// ObjectGroup modelling JavaScript WeakMap objects static let jsWeakMaps = ObjectGroup( name: "WeakMap",