parrotcode: Untitled | |
Contents | Language Implementations | .Net |
This document details the PMCs (Parrot Magic Cookies) that are used to read in .NET assemblies and provide access to the data held in them from PIR.
# Load an .NET CLI DLL or EXE file.
$P1 = new .DotNetAssembly
$P1 = "Example.dll"
$P1.load()
# Get name of loaded file.
$S1 = $P1
# Is it a DLL?
$I1 = $P1.is_dll()
if $I1 = 0 goto EXE
print "This is a DLL\n"
goto CONTINUE
EXE:
print "This is an EXE file\n"
CONTINUE:
# Get an array of classes.
$P2 = $P1.get_classes()
# Get the globals pseudo-class.
$P3 = $P1.get_global()
# Imagining $P2 is an array of DotNetClassMetadata PMCs...
$P3 = $P2[0]
# Get name and namespace.
$S1 = $P3
$S2 = $P3.get_namespace()
# Get flags bit vector
$I1 = $P3.get_flags()
# Get fields and methods.
$P4 = $P3.get_fields()
$P5 = $P3.get_methods()
# Imagine $P1 contains an array of DotNetMethodMetadata PMCs...
$P2 = $P1[0]
# Get the name of the method.
$S1 = $P2
# Get the position of the blob holding a signature for the method.
$I0 = $P2.get_signature()
# Get flags bit vector
$I1 = $P2.get_flags()
# Get the method implementation (a DotNetBytecode PMC).
$P4 = $P2.get_bytecode()
# Get parameters (an array of DotNetParamMetadata PMCs).
$P5 = $P2.get_params()
# Imagine $P1 contains an array of DotNetFieldMetadata PMCs...
$P2 = $P1[0]
# Get the name of the field.
$S1 = $P2
# Get the position of the blob holding a signature for the field.
$I0 = $P2.get_signature()
# Get flags bit vector
$I1 = $P2.get_flags()
# Imagine $P1 contains an array of DotNetParamMetadata PMCs...
$P2 = $P1[0]
# Get the name of the parameter.
$S1 = $P2
# Get flags for the parameter.
$I0 = $P2.get_flags()
# Get sequence number.
$I1 = $P2.get_sequence()
$P0 = new DotNetSignature
$S0 = assembly.get_blob(blob_position)
$P0 = $S0
type = $P0.read_byte()
# etc
$P0.set_pos(0)
$I0 = $P0.read_uint8()
$N0 = $P0.read_float32()
$I1 = $P0.get_pos() # $I1 will contain 5
# Imagining $P2 is an array of DotNetTypeRefMetadata PMCs...
$P3 = $P2[0]
# Get name and namespace.
$S1 = $P3
$S2 = $P3.get_namespace()
# Get resolution scope.
$I1 = $P3.get_resolution_scope()
|