本文整理汇总了C#中Jurassic.Compiler.ILGenerator.BranchIfLessThanOrEqual方法的典型用法代码示例。如果您正苦于以下问题:C# ILGenerator.BranchIfLessThanOrEqual方法的具体用法?C# ILGenerator.BranchIfLessThanOrEqual怎么用?C# ILGenerator.BranchIfLessThanOrEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jurassic.Compiler.ILGenerator
的用法示例。
在下文中一共展示了ILGenerator.BranchIfLessThanOrEqual方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateCode
//.........这里部分代码省略.........
generator.Branch(endOfIf);
generator.DefineLabelPosition(startOfFalse);
// thisObject = TypeConverter.ToObject(thisObject);
EmitHelpers.LoadThis(generator);
EmitConversion.ToObject(generator, PrimitiveType.Any);
// }
generator.DefineLabelPosition(endOfIf);
EmitHelpers.StoreThis(generator);
}
// Transfer the function name into the scope.
if (string.IsNullOrEmpty(this.Name) == false &&
this.ArgumentNames.Contains(this.Name) == false &&
optimizationInfo.MethodOptimizationHints.HasVariable(this.Name))
{
EmitHelpers.LoadFunction(generator);
var functionName = new NameExpression(this.InitialScope, this.Name);
functionName.GenerateSet(generator, optimizationInfo, PrimitiveType.Any, false);
}
// Transfer the arguments object into the scope.
if (this.MethodOptimizationHints.HasArguments == true && this.ArgumentNames.Contains("arguments") == false)
{
// prototype
EmitHelpers.LoadScriptEngine(generator);
generator.Call(ReflectionHelpers.ScriptEngine_Object);
generator.Call(ReflectionHelpers.FunctionInstance_InstancePrototype);
// callee
EmitHelpers.LoadFunction(generator);
generator.CastClass(typeof(Library.UserDefinedFunction));
// scope
EmitHelpers.LoadScope(generator);
generator.CastClass(typeof(DeclarativeScope));
// argumentValues
EmitHelpers.LoadArgumentsArray(generator);
generator.NewObject(ReflectionHelpers.Arguments_Constructor);
var arguments = new NameExpression(this.InitialScope, "arguments");
arguments.GenerateSet(generator, optimizationInfo, PrimitiveType.Any, false);
}
// Transfer the argument values into the scope.
// Note: the arguments array can be smaller than expected.
if (this.ArgumentNames.Count > 0)
{
var endOfArguments = generator.CreateLabel();
for (int i = 0; i < this.ArgumentNames.Count; i++)
{
// Check if a duplicate argument name exists.
bool duplicate = false;
for (int j = i + 1; j < this.ArgumentNames.Count; j++)
if (this.ArgumentNames[i] == this.ArgumentNames[j])
{
duplicate = true;
break;
}
if (duplicate == true)
continue;
// Check if an array element exists.
EmitHelpers.LoadArgumentsArray(generator);
generator.LoadArrayLength();
generator.LoadInt32(i);
generator.BranchIfLessThanOrEqual(endOfArguments);
// Store the array element in the scope.
EmitHelpers.LoadArgumentsArray(generator);
generator.LoadInt32(i);
generator.LoadArrayElement(typeof(object));
var argument = new NameExpression(this.InitialScope, this.ArgumentNames[i]);
argument.GenerateSet(generator, optimizationInfo, PrimitiveType.Any, false);
}
generator.DefineLabelPosition(endOfArguments);
}
// Initialize any declarations.
this.InitialScope.GenerateDeclarations(generator, optimizationInfo);
//EmitHelpers.LoadScope(generator);
//EmitConversion.ToObject(generator, PrimitiveType.Any);
//generator.Pop();
// Generate code for the body of the function.
this.AbstractSyntaxTree.GenerateCode(generator, optimizationInfo);
// Define the return target - this is where the return statement jumps to.
// ReturnTarget can be null if there were no return statements.
if (optimizationInfo.ReturnTarget != null)
generator.DefineLabelPosition(optimizationInfo.ReturnTarget);
// Load the return value. If the variable is null, there were no return statements.
if (optimizationInfo.ReturnVariable != null)
// Return the value stored in the variable. Will be null if execution hits the end
// of the function without encountering any return statements.
generator.LoadVariable(optimizationInfo.ReturnVariable);
else
// There were no return statements - return null.
generator.LoadNull();
}