11using System ;
2- using System . Runtime . CompilerServices ;
3- #if NET45 || NET471 || NETSTANDARD || NETCOREAPP2_1
4- using System . Runtime . InteropServices ;
5- #endif
6- using System . Text ;
7- #if NET40
8-
9- using PolyfillsForOldDotNet . System . Runtime . InteropServices ;
10- #endif
112
123namespace JavaScriptEngineSwitcher . ChakraCore . JsRt
134{
@@ -165,7 +156,7 @@ public static uint Idle()
165156 public static JsValue ParseScript ( string script , JsSourceContext sourceContext , string sourceUrl ,
166157 ref JsParseScriptAttributes parseAttributes )
167158 {
168- JsValue scriptValue = CreateExternalArrayBufferFromScriptCode ( script , ref parseAttributes ) ;
159+ JsValue scriptValue = JsValue . FromString ( script ) ;
169160 scriptValue . AddRef ( ) ;
170161
171162 JsValue sourceUrlValue = JsValue . FromString ( sourceUrl ) ;
@@ -244,7 +235,7 @@ public static JsValue ParseSerializedScript(string script, byte[] buffer,
244235 public static JsValue RunScript ( string script , JsSourceContext sourceContext , string sourceUrl ,
245236 ref JsParseScriptAttributes parseAttributes )
246237 {
247- JsValue scriptValue = CreateExternalArrayBufferFromScriptCode ( script , ref parseAttributes ) ;
238+ JsValue scriptValue = JsValue . FromString ( script ) ;
248239 scriptValue . AddRef ( ) ;
249240
250241 JsValue sourceUrlValue = JsValue . FromString ( sourceUrl ) ;
@@ -326,7 +317,7 @@ public static JsValue RunSerializedScript(string script, byte[] buffer,
326317 /// <returns>The buffer to put the serialized script into</returns>
327318 public static byte [ ] SerializeScript ( string script , ref JsParseScriptAttributes parseAttributes )
328319 {
329- JsValue scriptValue = CreateExternalArrayBufferFromScriptCode ( script , ref parseAttributes ) ;
320+ JsValue scriptValue = JsValue . FromString ( script ) ;
330321 scriptValue . AddRef ( ) ;
331322
332323 JsValue bufferValue ;
@@ -346,33 +337,6 @@ public static byte[] SerializeScript(string script, ref JsParseScriptAttributes
346337 return buffer ;
347338 }
348339
349- /// <summary>
350- /// Creates a Javascript <c>ArrayBuffer</c> object from script code
351- /// </summary>
352- /// <param name="script">Script code</param>
353- /// <param name="parseAttributes">Attribute mask for parsing the script</param>
354- /// <returns>The new <c>ArrayBuffer</c> object</returns>
355- [ MethodImpl ( ( MethodImplOptions ) 256 /* AggressiveInlining */ ) ]
356- private static JsValue CreateExternalArrayBufferFromScriptCode ( string script ,
357- ref JsParseScriptAttributes parseAttributes )
358- {
359- Encoding encoding ;
360-
361- if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
362- {
363- encoding = Encoding . Unicode ;
364- parseAttributes |= JsParseScriptAttributes . ArrayBufferIsUtf16Encoded ;
365- }
366- else
367- {
368- encoding = Encoding . UTF8 ;
369- }
370-
371- JsValue scriptValue = JsValue . CreateExternalArrayBuffer ( script , encoding ) ;
372-
373- return scriptValue ;
374- }
375-
376340 /// <summary>
377341 /// Returns a exception that caused the runtime of the current context to be in the
378342 /// exception state and resets the exception state for that runtime
0 commit comments