Module: Idl::Rvalue
- Extended by:
- T::Helpers, T::Sig
- Included in:
- ArrayIncludesAst, ArrayLiteralAst, ArraySizeAst, AryElementAccessAst, AryRangeAccessAst, BinaryExpressionAst, BitsCastAst, BuiltinVariableAst, ConcatenationExpressionAst, CsrFieldReadExpressionAst, CsrFunctionCallAst, CsrReadExpressionAst, DontCareLvalueAst, DontCareReturnAst, EnumArrayCastAst, EnumCastAst, EnumElementSizeAst, EnumRefAst, EnumSizeAst, FalseExpressionAst, FieldAccessExpressionAst, FunctionCallExpressionAst, IdAst, IntLiteralAst, ParenExpressionAst, ReplicationExpressionAst, SignCastAst, StringLiteralAst, TernaryOperatorExpressionAst, TrueExpressionAst, UnaryOperatorExpressionAst, WidthRevealAst
- Defined in:
- lib/idlc/ast.rb
Overview
interface for R-values (e.g., expressions that have a value)
Instance Method Summary collapse
- #max_value(symtab) ⇒ Object
- #min_value(symtab) ⇒ Object
- #truncate(value, width, signed) ⇒ Object
- #type(symtab) ⇒ Object
- #value(symtab) ⇒ Object
- #values(symtab) ⇒ Object
Instance Method Details
#max_value(symtab) ⇒ Object
874 875 876 877 878 879 880 881 |
# File 'lib/idlc/ast.rb', line 874 def max_value(symtab) value_result = T.cast(self, AstNode).value_try do return T.cast(T.must(value(symtab)), T.any(Integer, Symbol)) end T.cast(self, AstNode).value_else(value_result) do return :unknown end end |
#min_value(symtab) ⇒ Object
884 885 886 887 888 889 890 891 |
# File 'lib/idlc/ast.rb', line 884 def min_value(symtab) value_result = T.cast(self, AstNode).value_try do return T.cast(T.must(value(symtab)), T.any(Integer, Symbol)) end T.cast(self, AstNode).value_else(value_result) do return :unknown end end |
#truncate(value, width, signed) ⇒ Object
909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 |
# File 'lib/idlc/ast.rb', line 909 def truncate(value, width, signed) masked = value & ((1 << width) - 1) if signed # signed: need to mask and convert if masked[width - 1] == 1 # twos compliment value is 2^width - value -((1 << width) - masked) else masked end else # unsigned: simple truncation masked end end |
#type(symtab) ⇒ Object
847 |
# File 'lib/idlc/ast.rb', line 847 def type(symtab); end |
#value(symtab) ⇒ Object
871 |
# File 'lib/idlc/ast.rb', line 871 def value(symtab); end |
#values(symtab) ⇒ Object
906 |
# File 'lib/idlc/ast.rb', line 906 def values(symtab) = [value(symtab)] |