private static void CompileInspect(FunctionCompiler compiler, FunctionalNode inspectNode) { VariableReference input = inspectNode.InputTerminals[0].GetTrueVariable(); int typeSize = BytecodeInterpreterAllocator.GetTypeSize(input.Type.GetReferentType()); StaticDataBuilder staticData = compiler._builder.DefineStaticData(); staticData.Data = new byte[typeSize]; staticData.Identifier = StaticDataIdentifier.CreateFromNode(inspectNode); compiler.LoadValueAsReference(input); compiler._builder.EmitLoadStaticDataAddress(staticData); compiler._builder.EmitLoadIntegerImmediate(typeSize); compiler._builder.EmitCopyBytes_TEMP(); }
internal byte[] ReadStaticData(StaticDataIdentifier staticDataIdentifier) { if (_loading) { throw new InvalidOperationException("Cannot call ReadStaticData before calling FinalizeLoad"); } Tuple <int, int> staticDataLocation; if (_staticDataLocations.TryGetValue(staticDataIdentifier, out staticDataLocation)) { byte[] staticData = new byte[staticDataLocation.Item2]; Array.Copy(_memory, staticDataLocation.Item1, staticData, 0, staticDataLocation.Item2); return(staticData); } throw new ArgumentException("Static data not found", "staticDataIdentifier"); }