本文整理汇总了C#中JavaCompiler.Compilation.ByteCode.ByteCodeGenerator.DefineVariable方法的典型用法代码示例。如果您正苦于以下问题:C# ByteCodeGenerator.DefineVariable方法的具体用法?C# ByteCodeGenerator.DefineVariable怎么用?C# ByteCodeGenerator.DefineVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JavaCompiler.Compilation.ByteCode.ByteCodeGenerator
的用法示例。
在下文中一共展示了ByteCodeGenerator.DefineVariable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompileBody
private void CompileBody(CompileManager manager)
{
attributes = new List<CompileAttribute>();
generator = new ByteCodeGenerator(manager, (Method)constructor);
foreach (Method.Parameter parameter in constructor.Parameters)
{
generator.DefineVariable(parameter.Name, parameter.Type);
}
new ConstructorBlockCompiler(constructor.Body).Compile(generator);
attributes.Add(new CompileAttributeCode
{
NameIndex = manager.AddConstantUtf8(new CompileAttributeCode().Name),
Code = generator.GetBytes(),
Attributes = new List<CompileAttribute>(),
ExceptionTable = new List<CompileAttributeCode.ExceptionTableEntry>(),
MaxLocals = generator.MaxVariables,
MaxStack = generator.MaxStack
});
var stackMapTable = generator.StackMapTable;
if (stackMapTable != null)
{
stackMapTable.NameIndex = manager.AddConstantUtf8(stackMapTable.Name);
attributes.Add(stackMapTable);
}
}
示例2: Compile
public void Compile(ByteCodeGenerator generator)
{
var variable = generator.DefineVariable(node.Name, node.Type);
if (node.Initialiser != null)
{
new AssignmentCompiler(
new AssignmentNode.NormalAssignNode
{
Left = new PrimaryNode.TermIdentifierExpression { Identifier = node.Name },
Right = new TranslateNode { Child = node.Initialiser }
}).Compile(generator);
new LocalItem(generator, variable).Store();
}
}
示例3: CompileBody
private void CompileBody(CompileManager manager)
{
attributes = new List<CompileAttribute>();
generator = new ByteCodeGenerator(manager, method);
foreach (Method.Parameter parameter in method.Parameters)
{
generator.DefineVariable(parameter.Name, parameter.Type);
}
new BlockCompiler(method.Body).Compile(generator);
if (method.ReturnType.Name == "void")
{
generator.Emit([email protected]);
}
var code = new CompileAttributeCode
{
NameIndex = manager.AddConstantUtf8(new CompileAttributeCode().Name),
Code = generator.GetBytes(),
Attributes = new List<CompileAttribute>(),
ExceptionTable = new List<CompileAttributeCode.ExceptionTableEntry>(),
MaxLocals = generator.MaxVariables,
MaxStack = generator.MaxStack
};
var stackMapTable = generator.StackMapTable;
if (stackMapTable != null)
{
stackMapTable.NameIndex = manager.AddConstantUtf8(stackMapTable.Name);
code.Attributes.Add(stackMapTable);
}
attributes.Add(code);
}