doc/api/ruby/classes/Integer.src/M000018.html in ruby-vpi-20.0.0 vs doc/api/ruby/classes/Integer.src/M000018.html in ruby-vpi-21.0.0
- old
+ new
@@ -3,23 +3,29 @@
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
- <title>extend_sign (Integer)</title>
+ <title>unpack (Integer)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
- <pre><span class="ruby-comment cmt"># File lib/ruby-vpi/integer.rb, line 97</span>
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">extend_sign</span> <span class="ruby-identifier">aOrigWidth</span>, <span class="ruby-identifier">aExtWidth</span>
- <span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">self</span>
- <span class="ruby-identifier">maskWidth</span> = <span class="ruby-identifier">aExtWidth</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">aOrigWidth</span>
+ <pre><span class="ruby-comment cmt"># File lib/ruby-vpi/integer.rb, line 76</span>
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unpack</span> <span class="ruby-identifier">aPackedWidth</span>
+ <span class="ruby-identifier">bits</span> = <span class="ruby-identifier">length</span>
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">maskWidth</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">result</span>[<span class="ruby-identifier">aOrigWidth</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
- <span class="ruby-identifier">result</span> <span class="ruby-operator">|=</span> (<span class="ruby-identifier">maskWidth</span>.<span class="ruby-identifier">to_mask</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">aOrigWidth</span>)
+ <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">aPackedWidth</span> <span class="ruby-operator">>=</span> <span class="ruby-identifier">bits</span>
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">"packed width #{aPackedWidth} must be at least #{bits} for integer #{self}"</span>
<span class="ruby-keyword kw">end</span>
- <span class="ruby-identifier">result</span> <span class="ruby-operator">&</span> <span class="ruby-identifier">aExtWidth</span>.<span class="ruby-identifier">to_mask</span>
+ <span class="ruby-identifier">mask</span> = <span class="ruby-identifier">aPackedWidth</span>.<span class="ruby-identifier">to_mask</span>
+ <span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">self</span> <span class="ruby-operator">&</span> <span class="ruby-identifier">mask</span>
+
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span>[<span class="ruby-identifier">aPackedWidth</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
+ <span class="ruby-operator">-</span>((<span class="ruby-operator">-</span><span class="ruby-identifier">result</span>) <span class="ruby-operator">&</span> <span class="ruby-identifier">mask</span>)
+ <span class="ruby-keyword kw">else</span>
+ <span class="ruby-identifier">result</span>
+ <span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">end</span></pre>
</body>
</html>
\ No newline at end of file