Beispiel #1
0
 private string buildCharacter(DCharacter node)
 {
     return("'" + node.value + "'");
 }
Beispiel #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);
            }
        }
Beispiel #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);
            }
        }
Beispiel #4
0
 public virtual void visit(DCharacter phi)
 {
 }
Beispiel #5
0
 private string buildCharacter(DCharacter node)
 {
     return "'" + node.value + "'";
 }
Beispiel #6
0
 public virtual void visit(DCharacter phi) { }