⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 immutablearcinst.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        if (!name.isValid() || name.hasEmptySubnames() || name.isTempname() && name.getBasename() != BASENAME) throw new IllegalArgumentException("name");        if (nameDescriptor != null)            nameDescriptor = nameDescriptor.withDisplayWithoutParam();        if (tailNodeId < 0) throw new IllegalArgumentException("tailNodeId");        if (tailPortId == null) throw new NullPointerException("tailPortId");        if (tailLocation == null) throw new NullPointerException("tailLocation");        if (headNodeId < 0) throw new IllegalArgumentException("headNodeId");        if (headPortId == null) throw new NullPointerException("headPortId");        if (headLocation == null) throw new NullPointerException("headLocation");        if (gridExtendOverMin <= -MAX_EXTEND || gridExtendOverMin >= MAX_EXTEND)            throw new IllegalArgumentException("gridExtendOverMin");        int intGridExtendOverMin = (int)gridExtendOverMin;        angle %= 3600;        if (angle < 0) angle += 3600;        short shortAngle = updateAngle((short)angle, tailLocation, headLocation);        flags &= DATABASE_FLAGS;        if (!(tailPortId instanceof PrimitivePortId))            flags &= ~TAIL_NEGATED_MASK;        if (!(headPortId instanceof PrimitivePortId))            flags &= ~HEAD_NEGATED_MASK;        flags = updateManhattan(flags, headLocation, tailLocation, angle);        return new ImmutableArcInst(arcId, protoId, name, nameDescriptor,                tailNodeId, tailPortId, tailLocation,                headNodeId, headPortId, headLocation,                intGridExtendOverMin, shortAngle, flags, Variable.NULL_ARRAY);    }	/**	 * Returns ImmutableArcInst which differs from this ImmutableArcInst by name.	 * @param name node name key.	 * @return ImmutableArcInst which differs from this ImmutableArcInst by name.	 * @throws NullPointerException if name is null     * @throws IllegalArgumentException if name is not valid.	 */	public ImmutableArcInst withName(Name name) {		if (this.name.toString().equals(name.toString())) return this;		if (name == null) throw new NullPointerException("name");        if (!name.isValid() || name.hasEmptySubnames() || name.isTempname() && name.getBasename() != BASENAME) throw new IllegalArgumentException("name");		return new ImmutableArcInst(this.arcId, this.protoId, name, this.nameDescriptor,                this.tailNodeId, this.tailPortId, this.tailLocation,                this.headNodeId, this.headPortId, this.headLocation,                this.gridExtendOverMin, this.angle, this.flags, getVars());	}	/**	 * Returns ImmutableArcInst which differs from this ImmutableArcInst by name descriptor.     * @param nameDescriptor TextDescriptor of name	 * @return ImmutableArcInst which differs from this ImmutableArcInst by name descriptor.	 */	public ImmutableArcInst withNameDescriptor(TextDescriptor nameDescriptor) {        if (nameDescriptor != null)            nameDescriptor = nameDescriptor.withDisplayWithoutParam();        if (this.nameDescriptor == nameDescriptor) return this;		return new ImmutableArcInst(this.arcId, this.protoId, this.name, nameDescriptor,                this.tailNodeId, this.tailPortId, this.tailLocation,                this.headNodeId, this.headPortId, this.headLocation,                this.gridExtendOverMin, this.angle, this.flags, getVars());	}	/**	 * Returns ImmutableArcInst which differs from this ImmutableArcInst by tailLocation and headLocation.	 * @param tailLocation new tail location.     * @param headLocation new head location.	 * @return ImmutableArcInst which differs from this ImmutableArcInst by tailLocation and headLocation.	 * @throws NullPointerException if tailLocation is null.	 */	public ImmutableArcInst withLocations(EPoint tailLocation, EPoint headLocation) {		if (this.tailLocation.equals(tailLocation) && this.headLocation.equals(headLocation)) return this;		if (tailLocation == null) throw new NullPointerException("tailLocation");		if (headLocation == null) throw new NullPointerException("headLocation");        short angle = updateAngle(this.angle, tailLocation, headLocation);        int flags = updateManhattan(this.flags, headLocation, tailLocation, angle);		return new ImmutableArcInst(this.arcId, this.protoId, this.name, this.nameDescriptor,                this.tailNodeId, this.tailPortId, tailLocation,                this.headNodeId, this.headPortId, headLocation,                this.gridExtendOverMin, angle, flags, getVars());	}	/**     * Returns ImmutableArcInst which differs from this ImmutableArcInst by width.     * @param gridExtendOverMin extend of this arc over minimal arc of this type in grid units.     * @return ImmutableArcInst which differs from this ImmutableArcInst by width.     * @throws IllegalArgumentException if gridExtendOverMin is negative.     */	public ImmutableArcInst withGridExtendOverMin(long gridExtendOverMin) {        if (this.gridExtendOverMin == gridExtendOverMin) return this;        if (gridExtendOverMin <= -MAX_EXTEND || gridExtendOverMin >= MAX_EXTEND) throw new IllegalArgumentException("gridWidth");		return new ImmutableArcInst(this.arcId, this.protoId, this.name, this.nameDescriptor,                this.tailNodeId, this.tailPortId, this.tailLocation,                this.headNodeId, this.headPortId, this.headLocation,                (int)gridExtendOverMin, this.angle, this.flags, getVars());	}	/**	 * Returns ImmutableArcInst which differs from this ImmutableArcInst by angke.     * For arc with non-zero length returns ths ImmutableArcInst	 * @param angle angle in tenth-degrees.	 * @return ImmutableArcInst which differs from this ImmutableArcInst by user bits.	 */	public ImmutableArcInst withAngle(int angle) {        if (!tailLocation.equals(headLocation)) return this;        angle %= 3600;        if (angle < 0) angle += 3600;		if (this.angle == angle) return this;        short shortAngle = (short)angle;        int flags = updateManhattan(this.flags, this.headLocation, this.tailLocation, shortAngle);		return new ImmutableArcInst(this.arcId, this.protoId, this.name, this.nameDescriptor,                this.tailNodeId, this.tailPortId, this.tailLocation,                this.headNodeId, this.headPortId, this.headLocation,                this.gridExtendOverMin, shortAngle, flags, getVars());	}	/**	 * Returns ImmutableArcInst which differs from this ImmutableArcInst by user bits.	 * @param flags flag bits of this ImmutableArcInst.	 * @return ImmutableArcInst which differs from this ImmutableArcInst by user bits.	 */	public ImmutableArcInst withFlags(int flags) {        flags &= DATABASE_FLAGS;        if (!(tailPortId instanceof PrimitivePortId))            flags &= ~TAIL_NEGATED_MASK;        if (!(headPortId instanceof PrimitivePortId))            flags &= ~HEAD_NEGATED_MASK;        if ((this.flags & DATABASE_FLAGS) == flags) return this;        flags |= this.flags & MANHATTAN_MASK;		return new ImmutableArcInst(this.arcId, this.protoId, this.name, this.nameDescriptor,                this.tailNodeId, this.tailPortId, this.tailLocation,                this.headNodeId, this.headPortId, this.headLocation,                this.gridExtendOverMin, this.angle, flags, getVars());	}	/**	 * Returns ImmutableArcInst which differs from this ImmutableArcInst by flag bit.	 * @param flag Flag selector.     * @param value new value of flag.     * @return ImmutableArcInst which differs from this ImmutableArcInst by flag bit.	 */    public ImmutableArcInst withFlag(Flag flag, boolean value) {        return withFlags(flag.set(this.flags, value));    }	/**	 * Returns ImmutableArcInst which differs from this ImmutableArcInst by additional Variable.     * If this ImmutableArcInst has Variable with the same key as new, the old variable will not be in new     * ImmutableArcInst.	 * @param var additional Variable.	 * @return ImmutableArcInst with additional Variable.	 * @throws NullPointerException if var is null	 */    public ImmutableArcInst withVariable(Variable var) {        Variable[] vars = arrayWithVariable(var.withParam(false).withInherit(false));        if (this.getVars() == vars) return this;		return new ImmutableArcInst(this.arcId, this.protoId, this.name, this.nameDescriptor,                this.tailNodeId, this.tailPortId, this.tailLocation,                this.headNodeId, this.headPortId, this.headLocation,                this.gridExtendOverMin, this.angle, this.flags, vars);    }	/**	 * Returns ImmutableArcInst which differs from this ImmutableArcInst by removing Variable     * with the specified key. Returns this ImmutableArcInst if it doesn't contain variable with the specified key.	 * @param key Variable Key to remove.	 * @return ImmutableArcInst without Variable with the specified key.	 * @throws NullPointerException if key is null	 */    public ImmutableArcInst withoutVariable(Variable.Key key) {        Variable[] vars = arrayWithoutVariable(key);        if (this.getVars() == vars) return this;		return new ImmutableArcInst(this.arcId, this.protoId, this.name, this.nameDescriptor,                this.tailNodeId, this.tailPortId, this.tailLocation,                this.headNodeId, this.headPortId, this.headLocation,                this.gridExtendOverMin, this.angle, this.flags, vars);    }	/**	 * Returns ImmutableArcInst which differs from this ImmutableArcInst by renamed Ids.	 * @param idMapper a map from old Ids to new Ids.     * @return ImmutableArcInst with renamed Ids.	 */    ImmutableArcInst withRenamedIds(IdMapper idMapper) {        Variable[] vars = arrayWithRenamedIds(idMapper);        PortProtoId tailPortId = this.tailPortId;        PortProtoId headPortId = this.headPortId;        if (tailPortId instanceof ExportId)            tailPortId = idMapper.get((ExportId)tailPortId);        if (headPortId instanceof ExportId)            headPortId = idMapper.get((ExportId)headPortId);        if (getVars() == vars && this.tailPortId == tailPortId && this.headPortId == headPortId) return this;		return new ImmutableArcInst(this.arcId, this.protoId, this.name, this.nameDescriptor,                this.tailNodeId, tailPortId, this.tailLocation,                this.headNodeId, headPortId, this.headLocation,                this.gridExtendOverMin, this.angle, this.flags, vars);    }    private static short updateAngle(short angle, EPoint tailLocation, EPoint headLocation) {        if (tailLocation.equals(headLocation)) return angle;        return (short)GenMath.figureAngle(headLocation.getGridX() - tailLocation.getGridX(), headLocation.getGridY() - tailLocation.getGridY());    }    /**     * Writes this ImmutableArcInst to IdWriter.     * @param writer where to write.     */    void write(IdWriter writer) throws IOException {        writer.writeArcId(arcId);        writer.writeArcProtoId(protoId);        writer.writeNameKey(name);        writer.writeTextDescriptor(nameDescriptor);        writer.writeNodeId(tailNodeId);        writer.writePortProtoId(tailPortId);        writer.writePoint(tailLocation);        writer.writeNodeId(headNodeId);        writer.writePortProtoId(headPortId);        writer.writePoint(headLocation);        writer.writeInt(gridExtendOverMin);        writer.writeShort(angle);        writer.writeInt(flags);        super.write(writer);    }    /**     * Reads ImmutableArcInst from SnapshotReader.     * @param reader where to read.     */    static ImmutableArcInst read(IdReader reader) throws IOException {        int arcId = reader.readNodeId();        ArcProtoId protoId = reader.readArcProtoId();        Name name = reader.readNameKey();        TextDescriptor nameDescriptor = reader.readTextDescriptor();        int tailNodeId = reader.readNodeId();        PortProtoId tailPortId = reader.readPortProtoId();        EPoint tailLocation = reader.readPoint();        int headNodeId = reader.readNodeId();        PortProtoId headPortId = reader.readPortProtoId();        EPoint headLocation = reader.readPoint();        int gridExtendOverMin = reader.readInt();        short angle = reader.readShort();        int flags = reader.readInt();        boolean hasVars = reader.readBoolean();        Variable[] vars = hasVars ? readVars(reader) : Variable.NULL_ARRAY;        return new ImmutableArcInst(arcId, protoId, name, nameDescriptor,                tailNodeId, tailPortId, tailLocation, headNodeId, headPortId, headLocation, gridExtendOverMin,                updateAngle(angle, tailLocation, headLocation), flags, vars);    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -