How to use nilValue method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

EbxViewer.js

Source:EbxViewer.js Github

copy

Full Screen

1// Types that we can render directly.2var g_SimpleTypes = {3 "String": 1,4 "CString": 1,5 "Boolean": 2,6 "Int8": 1,7 "UInt8": 1,8 "Uint8": 1,9 "SByte": 1,10 "Int16": 1,11 "UInt16": 1,12 "Uint16": 1,13 "Int32": 3,14 "UInt32": 3,15 "Uint32": 3,16 "Int64": 1,17 "UInt64": 1,18 "Uint64": 1,19 "Float32": 1,20 "Single": 1,21 "Float64": 1,22 "Double": 1,23 "MathOp": 124}25var g_AdvancedTypes =26{27 "Vec2": ParseVec2,28 "Vec3": ParseVec3,29 "Vec4": ParseVec4,30 //"GUID": true,31 //"Guid": true,32 //"SHA1": true,33 //"Sha1": true,34 //"FileRef": true,35 //"ResourceRef": true,36 "LinearTransform": ParseLinearTransform,37 //"EventSpec": true,38 //"DynamicEvent": true39}40function StringToUInt8(string)41{42 var DataArray = new Uint8Array(string.length);43 for (var i = 0; i < string.length; i++) 44 DataArray[i] = string.charCodeAt(i);45}46function Uint8ArrayToString( array )47{48 var Result = "";49 for (var i = 0; i < array.length; i++) 50 Result += String.fromCharCode(array[i]);51 return Result;52}53function DecryptEEString(inputString, guidString, offset) 54{55 if (guidString.length == 0)56 return null;57 if (inputString.length == 0)58 return null;59 var result = new Uint8Array(inputString.length);60 for (var i = 0; i < inputString.length; i++) 61 {62 var GuidIndex = (i + offset) % guidString.length;63 var InputStringChar = inputString[i];64 var InputGuidChar = guidString[GuidIndex];65 var Char = InputStringChar - InputGuidChar + 0xFF;66 result[i] = ((Char % 0xFF) + 1);67 }68 return result;69}70function Utf16ArrayToString(inputString)71{72 var Result = "";73 for (var i = 0; i < inputString.length; i += 2) 74 {75 if (i + 1 == inputString.length)76 {77 Result += String.fromCharCode(inputString.charCodeAt(i))78 }79 else80 {81 var Byte1 = inputString.charCodeAt(i);82 var Byte2 = inputString.charCodeAt(i + 1);83 Result += String.fromCharCode(((Byte2 << 8) & 0xFF00) + (Byte1 & 0x00FF));84 }85 }86 return Result;87}88var g_TypeFieldHandlers =89{90 "RngCharEntityData": function (classInstance)91 {92 var GuidString = classInstance["$guid"];93 if ((classInstance["$fields"]["Flags"]["$value"] & 0x100) == 0)94 GuidString = "00000000-0000-0000-0000-000000000000";95 var ClassDataArray = StringToUInt8(classInstance["$fields"]["In"]["$value"]);96 var GuidDataArray = StringToUInt8(GuidString);97 var String1 = DecryptEEString(ClassDataArray, GuidDataArray, GuidString.charCodeAt(12)); // classInstance["$fields"]["In"]["$value"]98 var DecryptedString = DecryptEEString(String1, StringToUInt8("xI&O45@3HUhgdfI!I45u&dhs@9U35df3!56IYOhdfI&31@48*56U!uiH)s+e&f-y"), GuidString.charCodeAt(20))99 console.log("String1: " + Uint8ArrayToString(String1));100 console.log("DecryptedString: " + Uint8ArrayToString(DecryptedString));101 //console.log("FindalSize: " + (Math.floor( fieldInstance["$value"].length / 2) + ( fieldInstance["$value"].length % 2 ) ) );102 return "In-Decrypted: " + Uint8ArrayToString(DecryptedString);103 },104 "SFBMEEntityData": function (classInstance, fieldInstance, fieldName)105 {106 if (fieldName != "In")107 return "";108 var GuidString = classInstance["$guid"];109 var ClassDataArray = StringToUInt8(fieldInstance["$value"]);110 var GuidDataArray = StringToUInt8(GuidString);111 var String1 = DecryptEEString(ClassDataArray, GuidDataArray, GuidString.charCodeAt(12));112 var DecryptedString = DecryptEEString(String1, StringToUInt8("xI&O45@3HUhgdfI!I45u&dhs@9U35df3!56IYOhdfI&31@48*56U!uiH)s+e&f-y"), GuidString.charCodeAt(20))113 console.log("DecryptedString: " + Uint8ArrayToString(DecryptedString));114 return fieldName + "-Decrypted: " + Uint8ArrayToString(DecryptedString );115 }116}117class EbxViewer118{119 constructor()120 {121 this.m_EbxCache = [];122 this.m_TypeHandlers = {};123 }124 AddToCache(key, data)125 {126 this.m_EbxCache[key] = data;127 }128 GetFromCache(key)129 {130 return this.m_EbxCache[key]131 }132 BuildInstance(partitionGuid, instanceGuid, parentPartition = null)133 {134 let s_Cached = this.GetFromCache(partitionGuid + instanceGuid)135 if (s_Cached != null)136 {137 console.log("Using cached ebx: [partition | instance]" + partitionGuid + " | " + instanceGuid);138 return s_Cached;139 }140 var Instance = s_EbxManager.FindInstance(partitionGuid, instanceGuid)141 if (Instance == null)142 return null;143 let content = "";144 content += `<h1 class="${(partitionGuid == parentPartition) ? "localRef" : "remoteRef"}">145 ${Instance["$type"]}146 ${(partitionGuid == parentPartition) ? `<partitionReference>${s_EbxManager.GetPartitionGuidPath(partitionGuid)}</partitionReference>` : ""}147 </h1>`148 content += `<div class="GuidReferences">149 <label>Partition: </label>150 <div class="guidReference">${partitionGuid.toUpperCase()}</div>151 <label>Instance: </label>152 <div class="guidReference">${instanceGuid.toUpperCase()}</div>153 </div>`;154 if (g_TypeFieldHandlers[Instance["$type"]] != null)155 current += g_TypeFieldHandlers[Instance["$type"]](Instance)156 content += `<ul type="first">157 ${(this.m_TypeHandlers[Instance["$type"]] != null) ? this.m_TypeHandlers[Instance["$type"]]() : ""}`;158 for (let FieldName in Instance["$fields"])159 content += this.HandleField(Instance["$fields"][FieldName], FieldName);160 161 162 content +=`</ul>`;163 this.AddToCache(partitionGuid + instanceGuid, content);164 return content;165 }166 HandleField(instance, field = null, subField = false, includeType = false) 167 {168 if (instance == null)169 return "";170 var content = "";171 var s_TypeElement = "";172 if (includeType && instance["$type"] != null)173 s_TypeElement = `<type class="aligned">${instance["$type"]}</type> `;174 content += 175 `<li class="${(instance["$array"] != null) ? "minimized" : ""}">176 ${s_TypeElement}`;177 if( field != null)178 content += `<field class="${subField ? "subField" : ""}">${field}</field>: `;179 if (instance["$array"] != null) // Handle array180 {181 content += ":";182 content += this.HandleArray(instance);183 }184 else if (instance["$ref"] != null) // Handle reference185 {186 content += this.HandleReference(instance);187 }188 else if (instance["$type"] != null && g_SimpleTypes[instance["$type"]]) // Handle simple189 {190 content += this.HandleSimple(instance["$value"], instance["$type"]);191 }192 else if (instance["$type"] != null && g_AdvancedTypes[instance["$type"]] != null) // Handle advanced193 {194 content += this.HandleAdvanced(instance["$value"], instance["$type"]);195 }196 else if (instance["$enum"] != null)197 {198 content += this.HandleEnum(instance["$enumValue"]);199 }200 else if ( typeof(instance) == "string" || 201 instance instanceof String || 202 typeof(instance) == "number" || 203 instance instanceof Number)204 content += this.HandleSimple(instance, null);205 else 206 {207 //if this is a ValueType, we fix it208 if (instance["$value"] != null)209 {210 content += `<label>${instance["$type"]}</label>`;211 content += `<ul type="2nd">`;212 content += this.HandleField(instance["$value"], null, true); //213 content += `</ul>`;214 }215 else216 {217 //content += `<ul type="2nd">`;218 //just do it, i think array uses this219 for (let key in instance)220 {221 content += this.HandleField(instance[key], key)222 }223 //content += `</ul>`;224 }225 }226 content += "</li>";227 if (content.indexOf("undefined") != -1)228 {229 console.log("Something went wrong. Debug!");230 debugger;231 }232 return content;233 }234 /*235 HandleSubField(instance)236 {237 var content = "";238 if (instance["$value"] != null)239 {240 content += this.HandleField(instance["$value"], null, false); //241 }242 else243 {244 //if (instance["$type"] == null)245 // return;246 content += '<ul type="2nd">';247 for( let key in instance)248 content += HandleField(instance[key], subField);249 content += "</ul>";250 }251 return content;252 }253 */254 HandleReference(instance, direct, directType)255 {256 // updated json support257 if (direct && instance != null && instance["$value"] != null)258 instance = instance["$value"];259 var content = "";260 let PartitionGuid = null;261 let InstanceGuid = null;262 if (instance != null)263 {264 if (direct &&265 instance['$partitionGuid'] != null &&266 instance['$instanceGuid'] != null)267 {268 PartitionGuid = instance["$partitionGuid"];269 InstanceGuid = instance["$instanceGuid"];270 instance["$type"] = directType;271 }272 else if (instance["$value"] != null && 273 instance["$value"]["$partitionGuid"] != null && 274 instance["$value"]["$instanceGuid"] != null)275 {276 PartitionGuid = instance["$value"]["$partitionGuid"];277 InstanceGuid = instance["$value"]["$instanceGuid"];278 }279 }280 if (PartitionGuid == null || InstanceGuid == null)281 return '<div class="ref"><nilValue>*nullRef*</nilValue></div>'282 content += `<div class="ref" partitionGuid="${PartitionGuid}" 283 instanceGuid="${InstanceGuid}" 284 parentPartition="${currentPartition}">`;285 content += `<h1 class="${(PartitionGuid == currentPartition) ? "localRef" : "remoteRef"}">`;286 var Instance = s_EbxManager.FindInstance(PartitionGuid, InstanceGuid, false);287 if (Instance != null)288 {289 content += `${Instance["$type"]}290 </h1>291 292 <div class="GuidReferences">293 <label>Partition:</label>294 <div class="guidReference">${PartitionGuid.toUpperCase()}</div>295 296 <label>Instance:</label>297 <div class="guidReference">${InstanceGuid.toUpperCase()}</div>298 </div>`;299 }300 else301 {302 content += `${instance["$type"]}303 <partitionReference>${s_EbxManager.GetPartitionGuidPath(PartitionGuid)}</partitionReference>304 </h1>305 306 <div class="GuidReferences">307 <label>Partition:</label>308 <div class="guidReference">${PartitionGuid.toUpperCase()}</div>309 310 <label>Instance:</label>311 <div class="guidReference">${InstanceGuid.toUpperCase()}</div>312 </div>`;313 return content;314 }315 content += '</div>';316 return content;317 }318 HandleReferencePost(partitionGuid, instanceGuid, parentPartition)319 {320 var content = "";321 var Instance = s_EbxManager.FindInstance(partitionGuid, instanceGuid);322 if (Instance != null)323 content += this.BuildInstance(partitionGuid, instanceGuid, parentPartition);324 else325 content += "<nilValue>Failed to fetch</nilValue>";326 return content;327 }328 HandleArray(instance)329 {330 if (instance['$value'] == null || 331 Object.values(instance['$value']).length == 0)332 return `<nilValue>*nullArray*</nilValue> \t| ${instance["$type"]}`;333 var content = "";334 // array length335 content += " <count>(" + Object.values(instance['$value']).length + ")</count>";336 // Array field type337 content += ` \t| ${instance["$type"]}`;338 content += '<ul class="array">';339 var i = 0;340 for( let key in instance['$value'])341 {342 let refInstance = instance['$value'][key];343 content += `<li><index>[${key}]</index>`;344 content += `<ul type="2nd">`;345 if (instance["$ref"] != null) // Handle ref346 content += this.HandleReference(refInstance, true, instance['$type']);347 else348 content += this.HandleField(refInstance);349 350 content += `</ul>`;351 content += "</li>";352 i++;353 }354 content += "</ul>";355 return content;356 }357 HandleSimple(value, type)358 {359 // If the value is not null or empty360 var content = "";361 if (g_SimpleTypes[type] != null &&362 g_SimpleTypes[type] == 2)363 content += `<value contenteditable="false" class="Boolean">${value}</value>`;364 else if (g_SimpleTypes[type] != null &&365 g_SimpleTypes[type] == 3 &&366 s_HashManager.ForceGetHash(value) != null)367 content += `<value class="Hash">${value} (\"${s_HashManager.ForceGetHash(value)}\")</value>`;368 else if (value !== null)369 content = `<value contenteditable="false" class="${type}">${value}</value>`;370 else371 content = `<nilValue class="${type}">0</nilValue>`;372 return content;373 }374 HandleAdvanced(value, type)375 {376 // If the value is not null or empty377 var content = "";378 if( !value)379 return "<nilValue>*null*</nilValue>";380 if (value)381 content = `<value class="${type}">`;382 if (g_AdvancedTypes[type] != null && g_AdvancedTypes[type] != true)383 content += g_AdvancedTypes[type](value);384 else385 content += value;386 content += "</value>";387 388 return content;389 }390 HandleEnum(enumValue)391 {392 if (enumValue != null)393 return `<value class="enum">${enumValue}</value>`;394 395 return "<nilValue>*unknownEnum*</nilValue";396 }397}398var g_EbxViewer = new EbxViewer();399/*400function BuildInstance(partitionGuid, instanceGuid, parentPartition = null)401{402 var current = "";403 if (CurrentlyLoaded[partitionGuid + instanceGuid] != null)404 {405 console.log("Using previously built instance:" + partitionGuid + instanceGuid);406 return CurrentlyLoaded[partitionGuid + instanceGuid];407 }408 console.log("Building instance: " + partitionGuid + " | " + instanceGuid);409 var Instance = s_EbxManager.FindInstance(partitionGuid, instanceGuid)410 if (Instance == null)411 return "*null*"412 // add TypeName 413 if (partitionGuid == parentPartition)414 {415 current += `<h1 class="localRef">${Instance["$type"]}</h1>`;416/*417current += 418`<div class="GuidReferences">419<label>Partition:</label>420<div class="guidReference">${partitionGuid.toUpperCase()}421</div> 422<label>Instance: </label>423<div class="guidReference">${instanceGuid.toUpperCase()}</div>424</div>`;425*426 }427 else428 {429 current += 430`<h1 class="remoteRef">${Instance["$type"]}431 <partitionReference>${s_EbxManager.GetPartitionGuidPath(partitionGuid)}</partitionReference>432</h1>`;433 }434 current += 435`<div class="GuidReferences">436 <label>Partition:</label>437 <div class="guidReference">${partitionGuid.toUpperCase()}</div> 438 <label>Instance: </label>439 <div class="guidReference">${instanceGuid.toUpperCase()}</div>440</div>`;441 current += '<ul type="first">';442 {443 keys = Object.keys(Instance["$fields"]);444 if (g_TypeFieldHandlers[Instance["$type"]] != null)445 current += g_TypeFieldHandlers[Instance["$type"]](Instance)446 keys.forEach(function (fieldName)447 {448 var FieldInstance = Instance["$fields"][fieldName];449 current += HandleField(FieldInstance, fieldName);450 });451 }452 current += "</ul>";453 CurrentlyLoaded[partitionGuid + instanceGuid] = current;454 return current;455}456function HandleField(instance, field = null, subField = false, includeType = false)457{458 var content = "";459 if (field != null && subField == false)460 {461 if( includeType )462 content += `<li><type>${instance["$type"]}</type> `;463 content += `<field>${field}</field>: `;464 }465 if (field != null && subField)466 content += ":<subfield>" + field + "</subfield>";467 if (instance["$array"] != null) // Handle array468 {469 content = '<li class="minimized"><type>' + instance["$type"] + '</type> <field>' + field + "</field>: ";470 content += HandleArray(instance);471 content += "</li>"472 }473 else if (instance["$ref"] != null) // Handle reference474 {475 content += HandleReference(instance);476 }477 else if (instance["$type"] != null && simpleTypes[instance["$type"]]) // Handle simple478 {479 content += HandleSimple(instance["$value"], instance["$type"]);480 }481 else if (instance["$type"] != null && advancedTypes[instance["$type"]] != null) // Handle advanced482 {483 content += HandleAdvanced(instance["$value"], instance["$type"]);484 }485 else if (instance["$enum"] != null)486 {487 content += HandleEnum(instance["$enumValue"]);488 }489 else if (typeof instance == "string" || instance instanceof String)490 content += instance;491 else if (typeof instance == "number" || instance instanceof Number)492 content += instance;493 else494 content += HandleSubField(instance);495 if (content.indexOf("undefined") != -1)496 {497 console.log("Something went wrong. Debug!");498 }499 return content;500}501function HandleSubField(instance)502{503 var content = "";504 if (instance["$value"] != null)505 {506 content += HandleField(instance["$value"], null, true); //507 }508 else509 {510 //if (instance["$type"] == null)511 // return;512 content += '<ul type="2nd">';513 Object.keys(instance).forEach(function (subField)514 {515 content += HandleField(this[subField], subField);516 }, instance);517 content += "</ul>";518 }519 return content;520}521function HandleReference(instance, direct, directType)522{523 var content = "";524 if (instance != null)525 {526 if (direct &&527 instance['$partitionGuid'] != null &&528 instance['$instanceGuid'] != null)529 {530 var PartitionGuid = instance["$partitionGuid"];531 var InstanceGuid = instance["$instanceGuid"];532 instance["$type"] = directType;533 }534 else535 {536 if (instance["$value"] != null && instance["$value"]["$partitionGuid"] != null && instance["$value"]["$instanceGuid"] != null)537 {538 var PartitionGuid = instance["$value"]["$partitionGuid"];539 var InstanceGuid = instance["$value"]["$instanceGuid"];540 }541 }542 }543 if (PartitionGuid == null || InstanceGuid == null)544 {545 return '<div class="ref" ' + "><nilValue>*nullRef*</nilValue></div>"546 }547 content += `<div class="ref" partitionGuid="${PartitionGuid}" 548 instanceGuid="${InstanceGuid}" 549 parentPartition="${currentPartition}">`;550 content += `<h1 class="${(PartitionGuid == currentPartition) ? "localRef" : "remoteRef"}">`;551 var Instance = s_EbxManager.FindInstance(PartitionGuid, InstanceGuid, false);552 if (Instance != null)553 {554 //content += BuildInstance(loadedPartitions[partitionGuid][instanceGuid]);555 content += Instance["$type"] +556 '</h1>' +557 '<div class="GuidReferences">' +558 '<label>Partition:</label>' +559 '<div class="guidReference">' + PartitionGuid.toUpperCase() + '</div>' +560 ' ' +561 '<div class="GuidReferences">' +562 '<label>Instance:</label>' +563 '<div class="guidReference">' + InstanceGuid.toUpperCase() + '</div>' +564 '</div>';565 }566 else567 {568 /*569 if (loadedPartitions[partitionGuid] == null) 570 {571 *572 content += instance["$type"] +573 ' <partitionReference>' + s_EbxManager.GetPartitionGuidPath(PartitionGuid) + '</partitionReference>' +574 '</h1>' +575 '<div class="GuidReferences">' +576 '<label>Partition:</label>' +577 '<div class="guidReference">' + PartitionGuid.toUpperCase() + '</div>' +578 ' <div class="GuidReferences">' +579 '<label>Instance:</label>' +580 '<div class="guidReference">' + InstanceGuid.toUpperCase() + '</div>' +581 '</div>';582 return content;583 /*584 }585 if (loadedPartitions[partitionGuid][instanceGuid] != null) {586 content += loadedPartitions[partitionGuid][instanceGuid]["$type"] + ' <partitionReference>' + TryGetPartitionName(partitionGuid) + '</partitionReference></h1><div class="GuidReferences"><label>Partition:</label><div class="guidReference">' + partitionGuid.toUpperCase() + '</div> <div class="GuidReferences"><label>Instance:</label><div class="guidReference">' + instanceGuid.toUpperCase() + '</div></div>';587 //content += BuildInstance(loadedPartitions[partitionGuid][instanceGuid])588 } else {589 content += "<nilValue>Failed to fetch</nilValue>";590 }591 *592 }593 content += '</div>';594 return content;595}596function HandleReferencePost(partitionGuid, instanceGuid, parentPartition)597{598 var content = ""599 var Instance = s_EbxManager.FindInstance(partitionGuid, instanceGuid);600 if (Instance != null)601 content += BuildInstance(partitionGuid, instanceGuid, parentPartition);602 else603 content += "<nilValue>Failed to fetch</nilValue>";604 return content;605}606function HandleArray(instance)607{608 var content = "";609 content = " <count>(" + Object.values(instance['$value']).length + ")</count>";610 if (Object.values(instance['$value']).length == 0)611 {612 return content + "<nilValue>*nullArray*</nilValue>";613 }614 content += '<ul class="array">';615 var i = 1;616 Object.values(instance['$value']).forEach(function (refInstance)617 {618 if (instance["$ref"] != null) // Handle ref619 {620 content += "<li><index>[" + i + "]</index>";621 content += HandleReference(refInstance, true, instance['$type']);622 content += "</li>"623 }624 else625 {626 content += "<li><index>[" + i + "]</index>";627 content += HandleField(refInstance);628 content += "</li>";629 }630 /*631 if (instance["$ref"] != null) { // Handle ref632 content += "<li><index>[" + i + "]</index>";633 content += HandleReference(refInstance, true, instance['$type']);634 content += "</li>"635 } else { // Handle other types.636 if (simpleTypes[instance["$type"]]) { // Handle simple637 content += "<li><index>[" + i + "]</index>";638 content += HandleSimple(refInstance, instance["$type"]);639 content += "</li>"640 } else if (advancedTypes[instance["$type"]]) { // Handle simple641 content += "<li><index>[" + i + "]</index>";642 content += HandleAdvanced(refInstance, instance["$type"]);643 content += "</li>"644 } else {645 content += "<li><index>[" + i + "]</index>";646 content += HandleField(refInstance)647 content += "</li>"648 }649 }650 *651 i++;652 });653 content += "</ul>";654 return content;655}656function HandleEnum(enumValue)657{658 if (enumValue != null)659 {660 return '<value class="enum">' + enumValue + "</value>";661 }662 else663 {664 return "<nilValue>*unknownEnum*</nilValue";665 }666}667function HandleSimple(value, type)668{669 // If the value is not null or empty670 var content = "";671 if (simpleTypes[type] != null &&672 simpleTypes[type] == 2)673 content += '<value contenteditable="true" class="Boolean">' + value + "</value>";674 else if (simpleTypes[type] != null &&675 simpleTypes[type] == 3 &&676 s_HashManager.GetHashResult(value) != null)677 content += '<value class="Hash">' + s_HashManager.GetHashResult(value) + '</value>';678 else if (value !== null)679 content = '<value contenteditable="true" class="' + type + '">' + value + "</value>";680 else681 content = '<nilValue class="' + type + '">0</nilValue>';682 return content;683}684function HandleAdvanced(value, type)685{686 // If the value is not null or empty687 var content = "";688 if (value)689 {690 content = '<value class="' + type + '">';691 }692 if (advancedTypes[type] != null && advancedTypes[type] != true)693 content += advancedTypes[type](value);694 else695 content += value;696 if (content != '<value class="' + type + '">')697 {698 content += "</value>"699 }700 else701 { //Value is null or empty.702 content = "<nilValue>*null*</nilValue>";703 }704 return content;705}706function HandleEvent(value)707{708 var content = ':<subfield>EventSpec</subfield><ul type="2nd">';709 content += '<li><field>Id</field><value class="EventSpec">';710 if (GetHashResult([value["Id"]["$value"]]) != null)711 content += GetHashResult([value["Id"]["$value"]]);712 else713 content += value["Id"]["$value"];714 content += "</value></li></ul>";715 return content;716}717*/718function ParseVec2(value, raw = false)719{720 if (value == null)721 return "<nilValue>*null*</nilValue>";722 var content = "";723 if (raw == true)724 content += "Vec3(";725 content += value["x"]["$value"] + ", " + value["y"]["$value"];726 if (raw == true)727 content += ")";728 return content;729}730function ParseVec3(value, raw = false)731{732 if (value == null)733 return "<nilValue>*null*</nilValue>";734 var content = "";735 if (raw == true)736 content += "Vec3(";737 content += value["x"]["$value"] + ", " + value["y"]["$value"] + ", " + value["z"]["$value"];738 if (raw == true)739 content += ")";740 return content;741}742function ParseVec4(value, raw = false)743{744 if (value == null)745 return "<nilValue>*null*</nilValue>";746 var content = "";747 if (raw == true)748 content += "Vec4(";749 content += value["x"]["$value"] + ", " + value["y"]["$value"] + ", " + value["z"]["$value"] + ", " + value["w"]["$value"];750 if (raw == true)751 content += ")";752 return content;753}754function ParseLinearTransform(value)755{756 if (value == null)757 return "<nilValue>*null*</nilValue>";758 // Fix for uppercase members759 let s_Right = null;760 let s_Up = null;761 let s_Forward = null;762 let s_Trans = null;763 if (value["right"] != null)764 {765 s_Right = value["right"]["$value"];766 s_Up = value["up"]["$value"];767 s_Forward = value["forward"]["$value"];768 s_Trans = value["trans"]["$value"];769 }770 else771 {772 s_Right = value["Right"]["$value"];773 s_Up = value["Up"]["$value"];774 s_Forward = value["Forward"]["$value"];775 s_Trans = value["Trans"]["$value"];776 }777 var content = '<ul type="2nd">' +778 '<value class="LinearTransform">' +779 '<li>LinearTransform(';780 content += '<li>' + ParseVec3(s_Right) + ",</li>";781 content += '<li>' + ParseVec3(s_Up) + ",</li>";;782 content += '<li>' + ParseVec3(s_Forward) + ",</li>";783 content += '<li>' + ParseVec3(s_Trans) + "</li>";784 content += ')</li>' +785 '</value>' +786 '</ul>';787 return content;...

Full Screen

Full Screen

Interpreter.ts

Source:Interpreter.ts Github

copy

Full Screen

1import { ExecutionContext } from './ExecutionContext';2import { ParsingContext } from '../compiler/ParsingContext';3import { Nodes, PhaseFlags } from '../compiler/nodes';4import { BuiltInFunction } from './Value';5import { LysSemanticError, PositionCapableError } from '../compiler/NodeError';6import { last } from '../compiler/helpers';7const NilValue = Nodes.Nil.instance;8const builtIns: Record<string, BuiltInFunction> = {9 include: async function(_input, _context, _parsingContext) {10 return NilValue; // a interpret(parse(`()`), context, parsingContext);11 },12 'fn*': async function(input, context, _) {13 return new Nodes.FunctionNode(input.values.splice(1), context);14 },15 def: async function(input, context, parsingContext) {16 const sym = input.values[1];17 const value = input.values.length > 2 ? input.values[input.values.length - 1] : null;18 if (sym instanceof Nodes.SymbolNode) {19 const variable = new Nodes.Var(sym, async () =>20 value ? (await interpret(value, context, parsingContext)) || NilValue : NilValue21 );22 context.scope.set(sym.name, variable);23 return variable;24 } else {25 throw parsingContext.messageCollector.error(new LysSemanticError('Invalid symbol', sym));26 }27 },28 'core/list': async function(input, context, parsingContext) {29 const list: Nodes.Atom[] = [];30 for (let i = 0; i < input.values.length; i++) {31 list.push(await interpret(input.values[i], context, parsingContext));32 }33 return new Nodes.List(list);34 },35 'core/deref': async function(input, context, parsingContext) {36 const arg: Nodes.Atom = input.values[1];37 if (!arg) {38 throw parsingContext.messageCollector.error(new LysSemanticError(`(deref .) requires an argument`, input));39 }40 let argValue = await interpret(arg, context, parsingContext);41 if (argValue instanceof Nodes.Var) {42 return argValue.getValue();43 } else {44 throw parsingContext.messageCollector.error(45 new LysSemanticError(`(deref .): A var is required, got ${argValue}`, argValue)46 );47 }48 },49 'core/var': async function(input, context, parsingContext) {50 const symbol: Nodes.Atom = input.values[1];51 if (!symbol) {52 throw parsingContext.messageCollector.error(new LysSemanticError(`Missing symbol`, input));53 }54 if (symbol instanceof Nodes.SymbolNode) {55 const resolved = context.get(symbol);56 if (!resolved) {57 throw parsingContext.messageCollector.error(new LysSemanticError(`Cannot resolve symbol`, symbol));58 }59 if (resolved instanceof Nodes.Var) {60 return resolved;61 }62 throw parsingContext.messageCollector.error(new LysSemanticError(`Not a symbol (${resolved})`, symbol));63 } else {64 throw parsingContext.messageCollector.error(65 new LysSemanticError(`(var .): A symbol is required, got ${symbol}`, symbol)66 );67 }68 },69 meta: async function(input, context, parsingContext) {70 const arg: Nodes.Atom = input.values[1];71 if (!arg) {72 throw parsingContext.messageCollector.error(new LysSemanticError(`(meta .): Missing argument`, input));73 }74 let argValue = await interpret(arg, context, parsingContext);75 if (argValue instanceof Nodes.Var) {76 return argValue.meta || NilValue;77 }78 return NilValue;79 },80 if: async function(input, context, parsingContext) {81 if (await interpret(input.values[1], context, parsingContext)) {82 return interpret(input.values[2], context, parsingContext);83 }84 return input.values[3] ? interpret(input.values[3], context, parsingContext) : NilValue;85 },86 'core/document': async function(input, context, parsingContext) {87 let result: Nodes.Atom[] = [];88 try {89 for (let i = 1; i < input.values.length; i++) {90 result.push(await interpret(input.values[i], context, parsingContext));91 }92 } catch (e) {93 throw parsingContext.messageCollector.error(e);94 }95 return new Nodes.PersistentVector(result);96 },97 'core/quote': async function(input, _, parsingContext) {98 if (input.values.length < 1) {99 throw parsingContext.messageCollector.error(new LysSemanticError(`(core/quote .): Missing argument`, input));100 }101 return input.values[1] || NilValue;102 }103};104async function interpretList(input: Nodes.List, context: ExecutionContext, parsingContext: ParsingContext) {105 if (input.values.length > 0) {106 const first = input.values[0];107 if (first instanceof Nodes.SymbolNode) {108 const varFromContext = context.get(first);109 if (varFromContext) {110 return call(await varFromContext.getValue(), input, context, parsingContext);111 }112 if (first.fqn in builtIns) {113 return builtIns[first.fqn](input, context, parsingContext);114 }115 throw parsingContext.messageCollector.error(new LysSemanticError(`Cannot resolve symbol "${first}"`, first));116 } else {117 const fn = await interpret(first, context, parsingContext);118 return call(fn, input, context, parsingContext);119 }120 } else {121 return Nodes.List.EMPTY;122 }123}124async function call(fn: Nodes.Atom, input: Nodes.List, context: ExecutionContext, parsingContext: ParsingContext) {125 if (fn instanceof Nodes.FunctionNode) {126 const scope = new Map();127 const childContext = new ExecutionContext(scope, fn.context);128 fn.params.values.forEach((sym, ix) => {129 if (sym instanceof Nodes.SymbolNode) {130 const value = input.values[ix + 1];131 const variable = new Nodes.Var(sym, async () =>132 value ? (await interpret(value, context, parsingContext)) || NilValue : NilValue133 );134 context.scope.set(sym.name, variable);135 return variable;136 } else {137 throw parsingContext.messageCollector.error(new LysSemanticError(`Parameters must be Symbol`, sym));138 }139 });140 const list: Nodes.Atom[] = [];141 const body = fn.body;142 for (let i = 0; i < body.length; i++) {143 list.push(await interpret(body[i], childContext, parsingContext));144 }145 return last(list) || NilValue;146 }147 if (fn instanceof Nodes.Keyword) {148 if (input.values.length === 1) {149 throw parsingContext.messageCollector.error(new LysSemanticError(`Keyword selector: invalid arity`, input));150 }151 const first = await interpret(input.values[1], context, parsingContext);152 if (first instanceof Nodes.PersistentArrayMap) {153 return first.getValue(fn) || NilValue;154 } else if (first instanceof Nodes.PersistentSet) {155 return first.getValue(fn) || NilValue;156 }157 return NilValue;158 }159 throw parsingContext.messageCollector.error(new LysSemanticError(`${fn} is not a function`, input.values[0]));160}161async function interpret(162 input: Nodes.Atom,163 context: ExecutionContext,164 parsingContext: ParsingContext165): Promise<Nodes.Atom> {166 if (!input) {167 console.warn('Lisp', 'error', context.scope);168 return NilValue;169 }170 if (input instanceof Nodes.PersistentVector) {171 const list: Nodes.Atom[] = [];172 for (let i = 0; i < input.values.length; i++) {173 list.push(await interpret(input.values[i], context, parsingContext));174 }175 return new Nodes.PersistentVector(list);176 } else if (input instanceof Nodes.PersistentArrayMap) {177 const list: Nodes.Atom[] = [];178 for (let i = 0; i < input.values.length; i++) {179 list.push(await interpret(input.values[i], context, parsingContext));180 }181 return Nodes.PersistentArrayMap.fromValues(list, input.values);182 } else if (input instanceof Nodes.PersistentSet) {183 const list: Nodes.Atom[] = [];184 for (let i = 0; i < input.values.length; i++) {185 list.push(await interpret(input.values[i], context, parsingContext));186 }187 return Nodes.PersistentSet.fromValues(list, input.values);188 } else if (input instanceof Nodes.List) {189 return interpretList(input, context, parsingContext);190 } else if (input instanceof Nodes.SymbolNode) {191 const variable = context.get(input);192 if (variable) {193 return variable.getValue();194 }195 return NilValue;196 }197 return input;198}199export class Interpreter {200 lib = new Map<string, any>();201 private evalCounter = 0;202 constructor(public parsingContext: ParsingContext, lib: Record<string, any> = {}) {203 for (let i in lib) {204 this.lib.set(i, lib[i]);205 }206 }207 async eval(input: string) {208 const moduleName = `eval_${this.evalCounter++}`;209 this.parsingContext.invalidateModule(moduleName);210 this.parsingContext.getParsingPhaseForContent(moduleName, input);211 return this.run(moduleName);212 }213 async run(moduleName: string) {214 const atom = this.parsingContext.getPhase(moduleName, PhaseFlags.Semantic, true);215 try {216 return interpret(atom, new ExecutionContext(this.lib), this.parsingContext);217 } catch (e) {218 console.error(e);219 console.dir(e);220 if (e instanceof PositionCapableError) {221 this.parsingContext.messageCollector.errors.push(e);222 }223 throw e;224 }225 }...

Full Screen

Full Screen

NilValues.ts

Source:NilValues.ts Github

copy

Full Screen

1/*2 * This file is part of rasdaman community.3 *4 * Rasdaman community is free software: you can redistribute it and/or modify5 * it under the terms of the GNU General Public License as published by6 * the Free Software Foundation, either version 3 of the License, or7 * (at your option) any later version.8 *9 * Rasdaman community is distributed in the hope that it will be useful,10 * but WITHOUT ANY WARRANTY; without even the implied warranty of11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12 * GNU General Public License for more details.13 *14 * You should have received a copy of the GNU General Public License15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.16 *17 * Copyright 2003 - 2019 Peter Baumann /18 rasdaman GmbH.19 *20 * For more information please see <http://www.rasdaman.org>21 * or contact Peter Baumann via <baumann@rasdaman.com>.22 */23///<reference path="../../../common/_common.ts"/>24///<reference path="NilValue.ts"/>25/*26e.g:27<swe:NilValues>28 <swe:nilValue reason="http://www.opengis.net/def/nil/OGC/0/BelowDetectionRange">-INF</swe:nilValue>29 <swe:nilValue reason="http://www.opengis.net/def/nil/OGC/0/AboveDetectionRange">INF</swe:nilValue>30</swe:NilValues>31*/32module swe {33 export class NilValues {34 public nilValues:NilValue[];35 public constructor(source:rasdaman.common.ISerializedObject) {36 rasdaman.common.ArgumentValidator.isNotNull(source, "source");37 this.nilValues = [];38 source.getChildrenAsSerializedObjects("swe:NilValues").forEach(o => {39 this.nilValues.push(new NilValue(o));40 });41 }42 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { nilValue } = require('fast-check-monorepo');2console.log(nilValue());3const { nilValue } = require('fast-check-monorepo');4console.log(nilValue());5const { nilValue } = require('fast-check-monorepo');6console.log(nilValue());

Full Screen

Using AI Code Generation

copy

Full Screen

1const { nilValue } = require("fast-check-monorepo");2console.log(nilValue);3const { nilValue } = require("fast-check-monorepo");4console.log(nilValue);5const { nilValue } = require("fast-check-monorepo");6console.log(nilValue);7const { nilValue } = require("fast-check-monorepo");8console.log(nilValue);9const { nilValue } = require("fast-check-monorepo");10console.log(nilValue);11const { nilValue } = require("fast-check-monorepo");12console.log(nilValue);13const { nilValue } = require("fast-check-monorepo");14console.log(nilValue);15const { nilValue } = require("fast-check-monorepo");16console.log(nilValue);17const { nilValue } = require("fast-check-monorepo");18console.log(nilValue);19const { nilValue } = require("fast-check-monorepo");20console.log(nilValue);21const { nilValue } = require("fast-check-monorepo");22console.log(nilValue);23const { nilValue } = require("fast-check-monorepo");24console.log(nilValue);25const { nilValue } = require("fast-check-monorepo");26console.log(nilValue

Full Screen

Using AI Code Generation

copy

Full Screen

1const {nilValue} = require('fast-check-monorepo');2console.log(nilValue());3const {nilValue} = require('fast-check-monorepo');4console.log(nilValue());5const {nilValue} = require('fast-check-monorepo');6console.log(nilValue());7const {nilValue} = require('fast-check-monorepo');8console.log(nilValue());9const {nilValue} = require('fast-check-monorepo');10console.log(nilValue());

Full Screen

Using AI Code Generation

copy

Full Screen

1import { nilValue } from 'fast-check-monorepo';2const nil = nilValue();3import { nilValue } from 'fast-check';4const nil = nilValue();5import { nilValue } from 'fast-check-monorepo';6const nil = nilValue();7import { nilValue } from 'fast-check';8const nil = nilValue();92. In your test file, import the methods you want to use from `fast-check-monorepo`:10import { nilValue } from 'fast-check-monorepo';11const nil = nilValue();122. In your test file, import the methods you want to use from `fast-check`:13import { nilValue } from 'fast-check';14const nil = nilValue();

Full Screen

Using AI Code Generation

copy

Full Screen

1import { nilValue } from 'fast-check';2import { nilValue } from 'fast-check';3import { nilValue } from 'fast-check';4import { nilValue } from 'fast-check';5import { nilValue } from 'fast-check';6I expect to see only one import of `nilValue` method from `fast-check` library7import { nilValue } from 'fast-check';8I see multiple imports of `nilValue` method from `fast-check` library9import { nilValue } from 'fast-check';10import { nilValue } from 'fast-check';11import { nilValue } from 'fast-check';12import { nilValue } from 'fast-check';

Full Screen

Using AI Code Generation

copy

Full Screen

1const { nilValue } = require('fast-check-monorepo');2const nilValue = require('fast-check-monorepo').nilValue;3const nilValue = require('fast-check-monorepo').nilValue;4const { nilValue } = require('fast-check-monorepo');5const nilValue = require('fast-check-monorepo').nilValue;6const nilValue = require('fast-check-monorepo').nilValue;7const { nilValue } = require('fast-check-monorepo');8const nilValue = require('fast-check-monorepo').nilValue;9const nilValue = require('fast-check-monorepo').nilValue;

Full Screen

Using AI Code Generation

copy

Full Screen

1const { nilValue } = require('fast-check-monorepo');2const nil = nilValue();3console.log(nil);4const { nilValue } = require('fast-check-monorepo');5const nil = nilValue();6console.log(nil);7const { nilValue } = require('fast-check-monorepo');8const nil = nilValue();9console.log(nil);10const { nilValue } = require('fast-check-monorepo');11const nil = nilValue();12console.log(nil);13const { nilValue } = require('fast-check-monorepo');14const nil = nilValue();15console.log(nil);16const { nilValue } = require('fast-check-monorepo');17const nil = nilValue();18console.log(nil);19const { nilValue } = require('fast-check-monorepo');20const nil = nilValue();21console.log(nil);22const { nilValue } = require('fast-check-monorepo');23const nil = nilValue();24console.log(nil);25const { nilValue } = require('fast-check-monorepo');26const nil = nilValue();27console.log(nil);28const { nilValue } = require('fast-check-monorepo');29const nil = nilValue();30console.log(nil);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { nilValue } = require('fast-check-monorepo');2test('should return null', () => {3 const result = nilValue();4 expect(result).toBeNull();5});6const { nilValue } = require('fast-check-monorepo');7test('should return null', () => {8 const result = nilValue();9 expect(result).toBeNull();10});11const { nilValue } = require('fast-check-monorepo');12test('should return null', () => {13 const result = nilValue();14 expect(result).toBeNull();15});

Full Screen

Using AI Code Generation

copy

Full Screen

1const {nilValue} = require('fast-check');2const nil = nilValue();3console.log(`nil: ${nil}`);4const {nilValue} = require('fast-check');5const nil = nilValue();6console.log(`nil: ${nil}`);7const {nilValue} = require('fast-check');8const nil = nilValue();9console.log(`nil: ${nil}`);10const {nilValue} = require('fast-check');11const nil = nilValue();12console.log(`nil: ${nil}`);13const {nilValue} = require('fast-check');14const nil = nilValue();15console.log(`nil: ${nil}`);16const {nilValue} = require('fast-check');17const nil = nilValue();18console.log(`nil: ${nil}`);19const {nilValue} = require('fast-check');20const nil = nilValue();21console.log(`nil: ${nil}`);22const {nilValue} = require('fast-check');23const nil = nilValue();24console.log(`nil: ${nil}`);25const {nilValue} = require('fast-check');26const nil = nilValue();27console.log(`nil: ${nil}`);28const {nilValue} = require('fast-check');

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful