Example #1
0
 private string buildBoolean(DBoolean node)
 {
     return(node.value ? "true" : "false");
 }
Example #2
0
        public override void visit(DConstant node)
        {
            DNode replacement = null;
            if (node.typeSet.numTypes == 1)
            {
                TypeUnit tu = node.typeSet[0];
                switch (tu.kind)
                {
                    case TypeUnit.Kind.Cell:
                    {
                        switch (tu.type.type)
                        {
                            case CellType.Bool:
                                replacement = new DBoolean(node.value != 0);
                                break;
                            case CellType.Character:
                                replacement = new DCharacter(Convert.ToChar(node.value));
                                break;
                            case CellType.Float:
                            {
                                //Debug.Assert(BitConverter.IsLittleEndian);
                                byte[] bits = BitConverter.GetBytes(node.value);
                                float v = BitConverter.ToSingle(bits, 0);
                                replacement = new DFloat(v);
                                break;
                            }
                            case CellType.Function:
                            {
                                Public p = graph_.file.publics[node.value >> 1];
                                Function function = graph_.file.lookupFunction(p.address);
                                replacement = new DFunction(p.address, function);
                                break;
                            }
                            default:
                                return;
                        }
                        break;
                    }

                    case TypeUnit.Kind.Array:
                    {
                        replacement = ConstantToReference(node, tu);
                        break;
                    }

                    default:
                        return;
                }
            }

            if (replacement == null && node.usedAsReference)
                replacement = ConstantToReference(node, null);
            if (replacement != null)
            {
                block_.nodes.insertAfter(node, replacement);
                node.replaceAllUsesWith(replacement);
            }
        }
Example #3
0
        public override void visit(DConstant node)
        {
            DNode replacement = null;

            if (node.typeSet.numTypes == 1)
            {
                TypeUnit tu = node.typeSet[0];
                switch (tu.kind)
                {
                case TypeUnit.Kind.Cell:
                {
                    switch (tu.type.type)
                    {
                    case CellType.Bool:
                        replacement = new DBoolean(node.value != 0);
                        break;

                    case CellType.Character:
                        replacement = new DCharacter(Convert.ToChar(node.value));
                        break;

                    case CellType.Float:
                    {
                        //Debug.Assert(BitConverter.IsLittleEndian);
                        byte[] bits = BitConverter.GetBytes(node.value);
                        float  v    = BitConverter.ToSingle(bits, 0);
                        replacement = new DFloat(v);
                        break;
                    }

                    case CellType.Function:
                    {
                        Public   p        = graph_.file.publics[node.value >> 1];
                        Function function = graph_.file.lookupFunction(p.address);
                        replacement = new DFunction(p.address, function);
                        break;
                    }

                    default:
                        return;
                    }
                    break;
                }

                case TypeUnit.Kind.Array:
                {
                    replacement = ConstantToReference(node, tu);
                    break;
                }

                default:
                    return;
                }
            }

            if (replacement == null && node.usedAsReference)
            {
                replacement = ConstantToReference(node, null);
            }
            if (replacement != null)
            {
                block_.nodes.insertAfter(node, replacement);
                node.replaceAllUsesWith(replacement);
            }
        }
Example #4
0
 public virtual void visit(DBoolean phi)
 {
 }
Example #5
0
 private string buildBoolean(DBoolean node)
 {
     return node.value ? "true" : "false";
 }
Example #6
0
 public virtual void visit(DBoolean phi) { }