public SCode ReadExtendedLambda(uint location) { Symbol name; Symbol [] formals; ReadFormals(location + 4, out name, out formals); object third = ReadObject(location + 8); EncodedObject argcount = new EncodedObject((uint)(int)third); uint optional = (argcount.Datum & 0x00FF); uint required = (argcount.Datum & 0xFF00) >> 8; bool rest = ((argcount.Datum & 0x10000) == 0x10000); SCode body = SCode.EnsureSCode(ReadObject(location)); return(ExtendedLambda.Make(name, formals, body, required, optional, rest)); }
public static bool ObjectSetType(out object answer, object arg0, object arg1) { TC newType = (TC)(int)arg0; // kludge!!!! if ((int)arg0 == 0 && (int)arg1 == 1) { answer = new NullEnvironment(); } else { switch (newType) { case TC.COMBINATION_2: answer = Combination2.Make((Hunk3)arg1); break; case TC.CONDITIONAL: answer = Conditional.Make((Hunk3)arg1); break; case TC.CONSTANT: answer = Constant.Decode((uint)(int)arg1); break; case TC.HUNK3_A: // Probably someone trying to mark a history object. answer = arg1; break; case TC.HUNK3_B: answer = arg1; break; case TC.ENVIRONMENT: object [] args = (object[])arg1; StandardClosure closure = (StandardClosure)args [0]; object [] actualArgs = new object [args.Length - 1]; for (int i = 0; i < actualArgs.Length; i++) { actualArgs [i] = args [i + 1]; } answer = new StandardEnvironment <StandardLambda, StandardClosure> (closure, actualArgs); break; // throw new NotImplementedException (); // // answer = (new InterpreterEnvironment ((object []) arg1)); case TC.EXTENDED_LAMBDA: answer = ExtendedLambda.Make((Hunk3)arg1); break; case TC.PCOMB0: answer = PrimitiveCombination0.Make((Primitive0)arg1); break; case TC.PCOMB2: answer = PrimitiveCombination2.Make((Hunk3)arg1); break; case TC.PRIMITIVE: if (!(arg1 is PrimitiveCombination0)) { throw new NotImplementedException("Object-set-type on primitive"); } answer = ((PrimitiveCombination0)arg1).Operator; break; case TC.RECORD: answer = new Record((object [])arg1); return(false); case TC.SEQUENCE_3: answer = new Sequence3((Hunk3)arg1); break; case TC.THE_ENVIRONMENT: answer = TheEnvironment.Make(); break; case TC.VARIABLE: answer = Variable.Make((Hunk3)arg1); break; case TC.VECTOR: // Someone wants to see what endian we are! char [] source = (char [])arg1; object [] result = new object [source.Length / 4]; result [1] = ((((((byte)source [3]) * 256) + ((byte)source [2])) * 256) + ((byte)source [1])) * 256 + ((byte)source [0]); result [0] = ((((((byte)source [7]) * 256) + ((byte)source [6])) * 256) + ((byte)source [5])) * 256 + ((byte)source [4]); answer = result; break; case TC.WEAK_CONS: answer = new WeakCons(((Cons)arg1).Car, ((Cons)arg1).Cdr); break; default: throw new NotImplementedException(); } } return(false); }