All Downloads are FREE. Search and download functionalities are using the official Maven repository.

flash.tools.debugger.concrete.LineFunctionContainer Maven / Gradle / Ivy

There is a newer version: 0.9.10
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package flash.tools.debugger.concrete;

import flash.swf.Action;
import flash.swf.ActionConstants;
import flash.swf.types.ActionList;
import flash.swf.actions.DefineFunction;
import flash.swf.debug.LineRecord;
import flash.tools.ActionLocation;
import flash.swf.MovieMetaData;
import flash.tools.SwfActionContainer;
import flash.util.Trace;

/**
 * This class extends the SwfActionContainer.
 * It performs a number of passes on the master
 * action list in order to extract line/function
 * mapping information.
 */
public class LineFunctionContainer extends SwfActionContainer
{
    public LineFunctionContainer(byte[] swf, byte[] swd)
	{
		super(swf, swd);

		// now that we've got all the action lists
		// nicely extracted and lined up we perform a 
		// bit of magic which modifies the DefineFunction 
		// records augmenting them with function names 
		// if they have have none.
		buildFunctionNames(getMasterList(), getHeader().version);
	}

	/**
	 * Use the action list located in the given location
	 * and return a new action location that corresponds
	 * to the next line record that is encountered
	 * after this location.  This routine does not 
	 * span into another action list.
	 */
	public ActionLocation endOfSourceLine(ActionLocation l)
	{
		ActionLocation current = new ActionLocation(l);
		int size = l.actions.size();
		for(int i= l.at+1; i we done
			Action a = l.actions.getAction(i);
			if (a.code == ActionList.sactionLineRecord)
				break;

			// hit a function => we are done
			if ( (a.code == ActionConstants.sactionDefineFunction) ||
				 (a.code == ActionConstants.sactionDefineFunction2) )
				break;

			current.at = i;
		}
		return current;
	}

	/**
	 * This routine is called from the DSwfInfo object
	 * and is used to obtain LineRecord information 
	 * from the ActionLists
	 */
	public void combForLineRecords(DSwfInfo info)
	{
		probeForLineRecords(getMasterList(), new ActionLocation(), info);
	}

	/**
	 * This routine is called from the DSwfInfo object
	 * and is used to obtain LineRecord information 
	 * from the ActionLists
	 * 
	 * The ActionLocation record is used as a holding
	 * container for state as we traverse the lists
	 */
	void probeForLineRecords(ActionList list, ActionLocation where, DSwfInfo info)
	{
		int size = list.size();
		for(int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy