Ejemplo n.º 1
0
        internal bool GetType(out object value)
        {
            if (this.trapOnReference)
            {
                switch (ReferenceTrap.GetTrapKind(this.val))
                {
                case TrapKind.TRAP_UNBOUND:
                    value = 0;
                    break;

                case TrapKind.TRAP_UNASSIGNED:
                    value = 1;
                    break;

                case TrapKind.TRAP_MACRO:
                    value = 3;
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
            else
            {
                value = 2; // NORMAL
            }
            return(false);
        }
Ejemplo n.º 2
0
        internal bool SafeGetValue(out object value)
        {
            if (this.trapOnReference)
            {
                switch (ReferenceTrap.GetTrapKind(this.val))
                {
                case TrapKind.TRAP_MACRO:
                    value = this.val;
                    break;

                default:
                    throw new NotImplementedException();
                }
                return(false);
            }
            else
            {
                value = this.val;
                return(false);
            }
        }
Ejemplo n.º 3
0
        public static bool ObjectDatum(out object answer, object arg)
        {
            Primitive prim = arg as Primitive;

            // make.scm does this song and dance with a primitive to find
            // if it exists.  We just sidestep by hacking object-datum to
            // return the primitive itself!
            if (prim != null)
            {
                answer = prim;
            }

            else if (arg is bool && (bool)arg == false)
            {
                answer = 0;
            }
            else if (arg == null)
            {
                answer = 9;
            }
            else if (arg is Int32)
            {
                answer = arg;
            }
            else if (arg is long)
            {
                answer = arg;
            }

            ////else {
            ////    int probe;
            ////    if (objectDatumDictionary.TryGetValue (arg, out probe)) {
            ////        return probe);
            ////    }
            ////    int datum = objectDatumCounter;
            ////    objectDatumDictionary.Add (arg, datum);
            ////    datumObjectDictionary.Add (datum, arg);
            ////    objectDatumCounter += 1;
            ////    return datum);
            else if (arg is ReferenceTrap)
            {
                ReferenceTrap rarg = (ReferenceTrap)arg;
                TrapKind      kind = ReferenceTrap.GetTrapKind(rarg);
                if (kind == TrapKind.TRAP_UNASSIGNED ||
                    kind == TrapKind.TRAP_UNBOUND ||
                    kind == TrapKind.TRAP_EXPENSIVE)
                {
                    answer = (int)kind;
                }
                else
                {
                    answer = arg.GetHashCode();
                }
            }
            else
            {
                answer = arg.GetHashCode();
            }
            if (answer is int && (int)answer < 0)
            {
                Debugger.Break();
            }
            return(false);
        }