/**
 * 
 */
package dspl.intermediate.instructions;

import java.util.ArrayList;

import dspl.intermediate.variable.Variable;

/**
 * CCallInstruction is the insrtuction used for invoking external *presumably c-compiled*
 * functions. 
 * Syntax: "ccall printf("hello %s\n", str1); 
 * printf is the function name
 * "hello %s\n" and str1 are the two parameters
 * @author David
 */
public class CCallInstruction extends Instruction {
	public String funcName; 
	public ArrayList parameters; 
	
	/**
	 * Constructor for CCallInstruction<br>
	 * Takes the function name to call
	 * @param funcName
	 */
	public CCallInstruction(String funcName) {
		super();
		this.funcName = funcName; 
		parameters = new ArrayList(); 
	}
	
	/**
	 * Adds a parameter to be passed (by pushing on the stack) to the function to be called
	 * @param v the variable to be pushed onto the stack
	 */
	public void addParameter(Variable v) { 
		parameters.add(v); 
	}
	
	/**
	 * Returns an arra of the parameters to be pased to the function.
	 * Assumed that parameters were added IN ORDER
	 * @return
	 */
	public Variable[] getParameters() { 
		return (Variable[]) parameters.toArray(new Variable[0]); 
	}
	
	/* (non-Javadoc)
	 * @see dspl.intermediate.instructions.Instruction#usesVariable(dspl.intermediate.variable.Variable)
	 */
	public boolean usesVariable(Variable v) {
		// TODO Auto-generated method stub
		return false;
	}

	public int getInstType() {
		return Instruction.INST_TYPE_CCALL;
	}

}
