예제 #1
0
 private string buildBoolean(DBoolean node)
 {
     return(node.value ? "true" : "false");
 }
예제 #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);
            }
        }
예제 #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);
            }
        }
예제 #4
0
파일: Nodes.cs 프로젝트: maxijabase/SPCode
 public virtual void visit(DBoolean phi)
 {
 }
예제 #5
0
 private string buildBoolean(DBoolean node)
 {
     return node.value ? "true" : "false";
 }
예제 #6
0
파일: Nodes.cs 프로젝트: not1ce111/Spedit
 public virtual void visit(DBoolean phi) { }