<commit_before>package openfl._internal.symbols.timeline;

// TODO: Force keeping of SWF symbols a different way?
import openfl._internal.formats.swf.SWFLite;
import openfl._internal.symbols.BitmapSymbol;
import openfl._internal.symbols.ButtonSymbol;
import openfl._internal.symbols.DynamicTextSymbol;
import openfl._internal.symbols.FontSymbol;
import openfl._internal.symbols.ShapeSymbol;
import openfl._internal.symbols.SpriteSymbol;
import openfl._internal.symbols.StaticTextSymbol;
import openfl._internal.symbols.SWFSymbol;
import openfl._internal.symbols.timeline.Frame;
import openfl._internal.symbols.timeline.FrameObject;
import openfl._internal.symbols.timeline.FrameObjectType;
import openfl._internal.utils.Log;
import openfl.display.DisplayObject;
import openfl.display.FrameLabel;
import openfl.display.MovieClip;
import openfl.display.Timeline;
import openfl.events.Event;
import openfl.filters.BitmapFilter;
import openfl.filters.BlurFilter;
import openfl.filters.ColorMatrixFilter;
import openfl.filters.ConvolutionFilter;
import openfl.filters.DisplacementMapFilter;
import openfl.filters.DropShadowFilter;
import openfl.filters.GlowFilter;
import openfl.geom.ColorTransform;
#if hscript
import hscript.Interp;
import hscript.Parser;
#end

@:access(openfl._internal.symbols)
@:access(openfl.display.DisplayObject)
@:access(openfl.geom.ColorTransform)
class SymbolTimeline extends Timeline
{
	@:noCompletion private var __activeInstances:Array<FrameSymbolInstance>;
	@:noCompletion private var __activeInstancesByFrameObjectID:Map<Int, FrameSymbolInstance>;
	@:noCompletion private var __instanceFields:Array<String>;
	@:noCompletion private var __movieClip:MovieClip;
	@:noCompletion private var __previousFrame:Int;
	@:noCompletion private var __swf:SWFLite;
	@:noCompletion private var __symbol:SpriteSymbol;

	public function new(swf:SWFLite, symbol:SpriteSymbol)
	{
		super();

		__swf = swf;
		__symbol = symbol;

		__previousFrame = -1;

		frameRate = swf.frameRate;
		totalFrames = __symbol.frames.length;
		framesLoaded = totalFrames;

		currentLabels = [];

		var frame:Int;
		var frameData:Frame;

		#if hscript
		var parser = null;
		#end

		for (i in 0...__symbol.frames.length)
		{
			frame = i + 1;
			frameData = __symbol.frames[i];

			if (frameData.label != null)
			{
				currentLabels.push(new FrameLabel(frameData.label, i + 1));
			}

			if (frameData.script != null)
			{
				if (frameScripts == null)
				{
					frameScripts = new Map();
				}

				frameScripts.set(frame, function(scope)
				{
					frameData.script();
				});
			}
			else if (frameData.scriptSource != null)
			{
				if (frameScripts == null)
				{
					frameScripts = new Map();
				}

				try
				{
					#if hscript
					if (parser == null)
					{
						parser = new Parser();
						parser.allowTypes = true;
					}

					var program = parser.parseString(frameData.scriptSource);
					var interp = new Interp();
					interp.variables.set("flash.events_Event", Event);

					var script = function(scope:MovieClip)
					{
						interp.variables.set("this", scope);
						interp.execute(program);
					};

					frameScripts.set(frame, script);
					#elseif js
					var script = untyped __js__("eval({0})", "(function(){" + frameData.scriptSource + "})");
					var wrapper = function()
					{
						try
						{
							script.call(this);
						}
						catch (e:Dynamic)
						{
							Log.info("Error evaluating frame script\n "
								+ e<commit_msg>Compile fix<commit_after>package openfl._internal.symbols.timeline;

// TODO: Force keeping of SWF symbols a different way?
import openfl._internal.formats.swf.SWFLite;
import openfl._internal.symbols.BitmapSymbol;
import openfl._internal.symbols.ButtonSymbol;
import openfl._internal.symbols.DynamicTextSymbol;
import openfl._internal.symbols.FontSymbol;
import openfl._internal.symbols.ShapeSymbol;
import openfl._internal.symbols.SpriteSymbol;
import openfl._internal.symbols.StaticTextSymbol;
import openfl._internal.symbols.SWFSymbol;
import openfl._internal.symbols.timeline.Frame;
import openfl._internal.symbols.timeline.FrameObject;
import openfl._internal.symbols.timeline.FrameObjectType;
import openfl._internal.utils.Log;
import openfl.display.DisplayObject;
import openfl.display.FrameLabel;
import openfl.display.MovieClip;
import openfl.display.Timeline;
import openfl.events.Event;
import openfl.filters.BitmapFilter;
import openfl.filters.BlurFilter;
import openfl.filters.ColorMatrixFilter;
import openfl.filters.ConvolutionFilter;
import openfl.filters.DisplacementMapFilter;
import openfl.filters.DropShadowFilter;
import openfl.filters.GlowFilter;
import openfl.geom.ColorTransform;
#if hscript
import hscript.Interp;
import hscript.Parser;
#end

@:access(openfl._internal.symbols)
@:access(openfl.display.DisplayObject)
@:access(openfl.geom.ColorTransform)
class SymbolTimeline extends Timeline
{
	@:noCompletion private var __activeInstances:Array<FrameSymbolInstance>;
	@:noCompletion private var __activeInstancesByFrameObjectID:Map<Int, FrameSymbolInstance>;
	@:noCompletion private var __instanceFields:Array<String>;
	@:noCompletion private var __movieClip:MovieClip;
	@:noCompletion private var __previousFrame:Int;
	@:noCompletion private var __swf:SWFLite;
	@:noCompletion private var __symbol:SpriteSymbol;

	public function new(swf:SWFLite, symbol:SpriteSymbol)
	{
		super();

		__swf = swf;
		__symbol = symbol;

		__previousFrame = -1;

		frameRate = swf.frameRate;
		totalFrames = __symbol.frames.length;
		framesLoaded = totalFrames;

		currentLabels = [];

		var frame:Int;
		var frameData:Frame;

		#if hscript
		var parser = null;
		#end

		for (i in 0...__symbol.frames.length)
		{
			frame = i + 1;
			frameData = __symbol.frames[i];

			if (frameData.label != null)
			{
				currentLabels.push(new FrameLabel(frameData.label, i + 1));
			}

			if (frameData.script != null)
			{
				if (frameScripts == null)
				{
					frameScripts = new Map();
				}

				frameScripts.set(frame, function(scope)
				{
					frameData.script();
				});
			}
			else if (frameData.scriptSource != null)
			{
				if (frameScripts == null)
				{
					frameScripts = new Map();
				}

				try
				{
					#if hscript
					if (parser == null)
					{
						parser = new Parser();
						parser.allowTypes = true;
					}

					var program = parser.parseString(frameData.scriptSource);
					var interp = new Interp();
					interp.variables.set("flash.events_Event", Event);

					var script = function(scope:MovieClip)
					{
						interp.variables.set("this", scope);
						interp.execute(program);
					};

					frameScripts.set(frame, script);
					#elseif js
					var script = untyped __js__("eval({0})", "(function(){" + frameData.scriptSource + "})");
					var wrapper = function(scope)
					{
						try
						{
							script.call(scope);
						}
						catch (e:Dynamic)
						{
							Log.info("Error evaluating frame script\n "
								+ e
{'fraction_non_alphanumeric': 0.11091854419410745, 'fraction_numerical': 0.0014442518775274408, 'mean_word_length': 4.018115942028985, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6643579', 'n_tokens_mistral': 2631, 'n_tokens_neox': 2173, 'n_words': 440}