<?php

function supfn_get_value($function,$name)
{
	//echo "Checking ";
	//print_r($function->memory);

	if (isset($function->memory[$name]))
	{				
		return $function->memory[$name];
	}
	if ($function->prnt !== FALSE)
	{
		return supfn_get_value($function->prnt,$name);
	}
	return FALSE;
}

function fn_get_c($aql)
{
	$data = $aql->Consume(1);
	
	//echo 'Getting Value :'.$data[0]->value;
	
	$res = supfn_get_value($aql,$data[0]->value);
	if ($res !== FALSE)
	{				
		array_push($aql->stack,unserialize(serialize($res)));	//$res);
	}
	else
	{		
		$a = new AQLStackElement();
		$a->typename = "error";
		$a->islist = true;
		$a->value = "Could not find memory location with that name.";
		array_push($aql->stack,$a);
	}
	
	//echo 'Getting Value :';
	//print_r($aql->stack);
	//echo '<br/>';
}
?>