11cb0ef41Sopenharmony_ci// Copyright 2019 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_cifunction formatOrigin(origin) { 61cb0ef41Sopenharmony_ci if (origin.nodeId) { 71cb0ef41Sopenharmony_ci return `#${origin.nodeId} in phase ${origin.phase}/${origin.reducer}`; 81cb0ef41Sopenharmony_ci } 91cb0ef41Sopenharmony_ci if (origin.bytecodePosition) { 101cb0ef41Sopenharmony_ci return `Bytecode line ${origin.bytecodePosition} in phase ${origin.phase}/${origin.reducer}`; 111cb0ef41Sopenharmony_ci } 121cb0ef41Sopenharmony_ci return "unknown origin"; 131cb0ef41Sopenharmony_ci} 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ciexport class NodeLabel { 161cb0ef41Sopenharmony_ci id: number; 171cb0ef41Sopenharmony_ci label: string; 181cb0ef41Sopenharmony_ci title: string; 191cb0ef41Sopenharmony_ci live: boolean; 201cb0ef41Sopenharmony_ci properties: string; 211cb0ef41Sopenharmony_ci sourcePosition: any; 221cb0ef41Sopenharmony_ci origin: any; 231cb0ef41Sopenharmony_ci opcode: string; 241cb0ef41Sopenharmony_ci control: boolean; 251cb0ef41Sopenharmony_ci opinfo: string; 261cb0ef41Sopenharmony_ci type: string; 271cb0ef41Sopenharmony_ci inplaceUpdatePhase: string; 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ci constructor(id: number, label: string, title: string, live: boolean, properties: string, sourcePosition: any, origin: any, opcode: string, control: boolean, opinfo: string, type: string) { 301cb0ef41Sopenharmony_ci this.id = id; 311cb0ef41Sopenharmony_ci this.label = label; 321cb0ef41Sopenharmony_ci this.title = title; 331cb0ef41Sopenharmony_ci this.live = live; 341cb0ef41Sopenharmony_ci this.properties = properties; 351cb0ef41Sopenharmony_ci this.sourcePosition = sourcePosition; 361cb0ef41Sopenharmony_ci this.origin = origin; 371cb0ef41Sopenharmony_ci this.opcode = opcode; 381cb0ef41Sopenharmony_ci this.control = control; 391cb0ef41Sopenharmony_ci this.opinfo = opinfo; 401cb0ef41Sopenharmony_ci this.type = type; 411cb0ef41Sopenharmony_ci this.inplaceUpdatePhase = null; 421cb0ef41Sopenharmony_ci } 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ci equals(that?: NodeLabel) { 451cb0ef41Sopenharmony_ci if (!that) return false; 461cb0ef41Sopenharmony_ci if (this.id != that.id) return false; 471cb0ef41Sopenharmony_ci if (this.label != that.label) return false; 481cb0ef41Sopenharmony_ci if (this.title != that.title) return false; 491cb0ef41Sopenharmony_ci if (this.live != that.live) return false; 501cb0ef41Sopenharmony_ci if (this.properties != that.properties) return false; 511cb0ef41Sopenharmony_ci if (this.opcode != that.opcode) return false; 521cb0ef41Sopenharmony_ci if (this.control != that.control) return false; 531cb0ef41Sopenharmony_ci if (this.opinfo != that.opinfo) return false; 541cb0ef41Sopenharmony_ci if (this.type != that.type) return false; 551cb0ef41Sopenharmony_ci return true; 561cb0ef41Sopenharmony_ci } 571cb0ef41Sopenharmony_ci 581cb0ef41Sopenharmony_ci getTitle() { 591cb0ef41Sopenharmony_ci let propsString = ""; 601cb0ef41Sopenharmony_ci if (this.properties === "") { 611cb0ef41Sopenharmony_ci propsString = "no properties"; 621cb0ef41Sopenharmony_ci } else { 631cb0ef41Sopenharmony_ci propsString = "[" + this.properties + "]"; 641cb0ef41Sopenharmony_ci } 651cb0ef41Sopenharmony_ci let title = this.title + "\n" + propsString + "\n" + this.opinfo; 661cb0ef41Sopenharmony_ci if (this.origin) { 671cb0ef41Sopenharmony_ci title += `\nOrigin: ${formatOrigin(this.origin)}`; 681cb0ef41Sopenharmony_ci } 691cb0ef41Sopenharmony_ci if (this.inplaceUpdatePhase) { 701cb0ef41Sopenharmony_ci title += `\nInplace update in phase: ${this.inplaceUpdatePhase}`; 711cb0ef41Sopenharmony_ci } 721cb0ef41Sopenharmony_ci return title; 731cb0ef41Sopenharmony_ci } 741cb0ef41Sopenharmony_ci 751cb0ef41Sopenharmony_ci getDisplayLabel() { 761cb0ef41Sopenharmony_ci const result = `${this.id}: ${this.label}`; 771cb0ef41Sopenharmony_ci if (result.length > 40) { 781cb0ef41Sopenharmony_ci return `${this.id}: ${this.opcode}`; 791cb0ef41Sopenharmony_ci } 801cb0ef41Sopenharmony_ci return result; 811cb0ef41Sopenharmony_ci } 821cb0ef41Sopenharmony_ci 831cb0ef41Sopenharmony_ci setInplaceUpdatePhase(name: string): any { 841cb0ef41Sopenharmony_ci this.inplaceUpdatePhase = name; 851cb0ef41Sopenharmony_ci } 861cb0ef41Sopenharmony_ci} 87