diff --git a/Sources/FuzzilliCli/Profiles/ArkProfile.swift b/Sources/FuzzilliCli/Profiles/ArkProfile.swift index 9e498b4ff932dd0b31ba62cf0ff0701665d86726..2a75d72634939a838c5d6af57d9afa678a4c1fb5 100644 --- a/Sources/FuzzilliCli/Profiles/ArkProfile.swift +++ b/Sources/FuzzilliCli/Profiles/ArkProfile.swift @@ -27,7 +27,7 @@ fileprivate let RunNearStackLimitGenerator = CodeGenerator("RunNearStackLimitGen /// ArkTS Generators fileprivate let ArkTSObjectInstanceGenerator = ValueGenerator("ArkTSObjectInstanceGenerator") { b, n in - let builtin = chooseUniform(from: ["Stack", "HashMap", "HashSet", "LinkedList", "List", "ArrayList", "TreeMap", "TreeSet"]) + let builtin = chooseUniform(from: ["Stack", "HashMap", "HashSet", "LinkedList", "List", "ArrayList", "TreeMap", "TreeSet", "LightWeightMap"]) let constructor = b.loadBuiltin(builtin) if ["TreeMap", "TreeSet"].contains(builtin) && probability(0.2) { //custom comparator for TreeMap and TreeSet will be generated only in 20% of cases let comparator = b.buildPlainFunction(with: .parameters(n: 2)) { args in @@ -65,6 +65,8 @@ fileprivate let arkTSArrayList = ILType.iterable + ILType.object(ofGroup: "Array fileprivate let arkTSTreeMap = ILType.iterable + ILType.object(ofGroup: "TreeMap", withProperties: ["length"], withMethods: ["isEmpty", "hasKey", "hasValue", "get", "getFirstKey", "getLastKey", "setAll", "set", "remove", "getLowerKey", "getHigherKey", "replace", "clear", "keys", "values", "forEach", "entries"]) /// Type of a ArkTS TreeSet object. fileprivate let arkTSTreeSet = ILType.iterable + ILType.object(ofGroup: "TreeSet", withProperties: ["length"], withMethods: ["isEmpty", "has", "getFirstValue", "getLastValue", "add", "remove", "getLowerValue", "getHigherValue", "popFirst", "popLast", "clear", "values", "forEach", "entries"]) +/// Type of a ArkTS LightWeightMap object. +fileprivate let arkTSLightWeightMap = ILType.iterable + ILType.object(ofGroup: "LightWeightMap", withProperties: ["length"], withMethods: ["isEmpty", "hasAll", "hasKey", "hasValue", "increaseCapacityTo", "get", "getIndexOfKey", "getIndexOfValue", "getKeyAt", "setAll", "set", "remove", "removeAt", "setValueAt", "getValueAt", "clear", "keys", "values", "forEach", "entries", "toString"]) /// Tpye of a ArkTS CollectionsMap object fileprivate let collectionsMap = ILType.iterable + ILType.object(ofGroup: "SharedMap", withProperties: ["size"], withMethods: ["entries", "keys", "values", "clear", "delete", "forEach", "get", "has", "set"]) @@ -85,6 +87,8 @@ fileprivate let arkTSArrayListConstructor = ILType.constructor([] => arkTSArrayL fileprivate let arkTSTreeMapConstructor = ILType.constructor([.opt(.function([.anything, .anything] => .boolean))] => arkTSTreeMap) /// Type of the ArkTS TreeSet constructor builtin. fileprivate let arkTSTreeSetConstructor = ILType.constructor([.opt(.function([.anything, .anything] => .boolean))] => arkTSTreeSet) +/// Type of the ArkTS LightWeightMap constructor builtin. +fileprivate let arkTSLightWeightMapConstructor = ILType.constructor([] => arkTSLightWeightMap) /// Type of the ArkTs CollectionsMap constructor builtin. fileprivate let collectionsMapConstructor = ILType.constructor([.object()] => collectionsMap) @@ -314,6 +318,37 @@ fileprivate let arkTSTreeSets = ObjectGroup( ] ) +fileprivate let arkTSLightWeightMaps = ObjectGroup( + name: "LightWeightMap", + instanceType: arkTSLightWeightMap, + properties: [ + "length" : .number, + ], + methods: [ + "isEmpty" : [] => .boolean, + "hasAll" : [.object(ofGroup: "LightWeightMap")] => .boolean, + "hasKey" : [.anything] => .boolean, + "hasValue" : [.anything] => .boolean, + "increaseCapacityTo" : [.number] => .undefined, + "get" : [.anything] => .anything, + "getIndexOfKey" : [.anything] => .number, + "getIndexOfValue" : [.anything] => .number, + "getKeyAt" : [.number] => .anything, + "setAll" : [.object(ofGroup: "LightWeightMap")] => .undefined, + "set" : [.anything, .anything] => .object(), + "remove" : [.anything] => .anything, + "removeAt" : [.number] => .boolean, + "setValueAt" : [.number, .anything] => .boolean, + "getValueAt" : [.number] => .anything, + "clear" : [] => .undefined, + "keys" : [] => .object(), + "values" : [] => .object(), + "forEach" : [.function([.opt(.anything), .opt(.anything), .opt(arkTSLightWeightMap)] => .undefined), .opt(.object())] => .undefined, + "entries" : [] => .object(), + "toString" : [] => .string + ] +) + let arkProfile = Profile( processArgs: { randomize in var args = [ @@ -339,6 +374,7 @@ let arkProfile = Profile( var ArrayList = arkPrivate.Load(arkPrivate.ArrayList); var TreeMap = arkPrivate.Load(arkPrivate.TreeMap); var TreeSet = arkPrivate.Load(arkPrivate.TreeSet); + var LightWeightMap = arkPrivate.Load(arkPrivate.LightWeightMap); function bgc() { for(let i=0; i<0x10000; i+=1) {new String();} @@ -391,6 +427,7 @@ let arkProfile = Profile( "ArrayList" : arkTSArrayListConstructor, "TreeMap" : arkTSTreeMapConstructor, "TreeSet" : arkTSTreeSetConstructor, + "LightWeightMap" : arkTSLightWeightMapConstructor, ], additionalObjectGroups: [ @@ -403,6 +440,7 @@ let arkProfile = Profile( arkTSArrayLists, arkTSTreeMaps, arkTSTreeSets, + arkTSLightWeightMaps, ], optionalPostProcessor: nil