WebAssemblySource.h 1.2 KB

1234567891011121314151617181920212223242526272829
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. #ifdef ENABLE_WASM
  7. namespace Js
  8. {
  9. class WebAssemblySource
  10. {
  11. BYTE* buffer;
  12. uint bufferLength;
  13. Js::Utf8SourceInfo* sourceInfo;
  14. public:
  15. WebAssemblySource(Var source, bool createNewContext, ScriptContext* scriptContext);
  16. // Caller is responsible to make a copy of the buffer source
  17. WebAssemblySource(BYTE* source, uint bufferLength, bool createNewContext, ScriptContext* scriptContext);
  18. BYTE* GetBuffer() const { return buffer; }
  19. uint GetBufferLength() const { return bufferLength; }
  20. Js::Utf8SourceInfo* GetSourceInfo() const { return sourceInfo; }
  21. private:
  22. void ReadBufferSource(Var val, ScriptContext* scriptContext);
  23. void CreateSourceInfo(bool createNewContext, ScriptContext* scriptContext);
  24. };
  25. }
  26. #endif