private void addFunctionStackVariablesToSortedList(Function func,
			List<Variable> sortedVariables) {

		for (Variable stackVar : func.getVariables(VariableFilter.STACK_VARIABLE_FILTER)) {
			Variable varImpl;
			if (isProtectedVariable(stackVar)) {
				continue;
			}
			try {
				if (stackVar instanceof Parameter) {
					varImpl = new ParameterImpl(null, stackVar.getDataType(),
						stackVar.getStackOffset(), program);
				}
				else {
					varImpl = new LocalVariableImpl(null, stackVar.getDataType(),
						stackVar.getStackOffset(), program);
				}
			}
			catch (InvalidInputException e) {
				continue; // skip variable
			}
			addVariableToSortedList(varImpl, sortedVariables);
		}
	}
Analyze a function to build a stack frame based on stack references.

@param f   function to analyze
@param monitor the task monitor that is checked to see if the command has
been cancelled.
@throws CancelledException if the user canceled this command
Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/NewFunctionStackAnalysisCmd.java