private void CreateFunctionInstructions(LightCompiler compiler) {
// emit context if we have a special local context
CodeContext globalContext = null;
compiler.Compile(Parent.LocalContext);
// emit name if necessary
PythonGlobalVariableExpression name = GetVariableExpression(_nameVariable) as PythonGlobalVariableExpression;
PythonGlobal globalName = null;
if (name == null) {
compiler.Compile(((IPythonGlobalExpression)GetVariableExpression(_nameVariable)).RawValue());
} else {
globalName = name.Global;
}
// emit defaults
int defaultCount = 0;
for (int i = _parameters.Length - 1; i >= 0; i--) {
var param = _parameters[i];
if (param.DefaultValue != null) {
compiler.Compile(AstUtils.Convert(param.DefaultValue, typeof(object)));
defaultCount++;
}
}
compiler.Instructions.Emit(new FunctionDefinitionInstruction(globalContext, this, defaultCount, globalName));
}