C# Class kOS.Safe.Compilation.Opcode

Mostra file Open project: KSP-KOS/KOS

Public Properties

Property Type Description
SourcePath kOS.Safe.Persistence.GlobalPath

Public Methods

Method Description
Execute ( ICpu cpu ) : void
GetArgumentDefs ( ) : IEnumerable

Return the list of member Properties that are part of what gets stored to machine langauge for this opcode.

InitMachineCodeData ( ) : void

This is intended to be called once, during the mod's initialization, and never again. It builds the Dictionaries that look up the type of opcode given its string name or code.

PopulateFromMLFields ( List fields ) : void

Starting from an empty instance of this opcode that you can assume was created from the default constructor, populate the Opcode's properties from a list of all the [MLFields] saved to the machine language file.
This needs to be overridden only if your Opcode has declared [MLField]'s. If your Opcode has no [MLFields] then the generic base version of this method works well enough.

TODO: Perhaps add an assert to the Init methods that will throw up a NagMessage if it detects an Opcode has be defined which has [MLFields] but lacks an override of this method.

ToString ( ) : string
TypeFromCode ( ByteCode code ) : Type

Given a string value of Code, find the Opcode Type that uses that as its CodeName.

TypeFromName ( string name ) : Type

Given a string value of Name, find the Opcode Type that uses that as its Name.

Protected Methods

Method Description
Opcode ( ) : System
PopStructureAssertEncapsulated ( ICpu cpu, bool barewordOkay = false ) : Structure

A utility function that will do the same as a cpu.PopStructureEncapsulated, but with an additional check to ensure the value atop the stack isn't the arg bottom marker.

PopValueAssert ( ICpu cpu, bool barewordOkay = false ) : object

A utility function that will do a cpu.PopValue, but with an additional check to ensure the value atop the stack isn't the arg bottom marker.

PopValueAssertEncapsulated ( ICpu cpu, bool barewordOkay = false ) : object

A utility function that will do the same as a cpu.PopValueEncapsulated, but with an additional check to ensure the value atop the stack isn't the arg bottom marker.

Private Methods

Method Description
MLFieldComparator ( MLArgInfo a1, MLArgInfo a2 ) : int

Delegate function used for Sort() of the MLFields on an Opcode. Should only be called on properties that have [MLField] attributes on them.

Method Details

Execute() public method

public Execute ( ICpu cpu ) : void
cpu ICpu
return void

GetArgumentDefs() public method

Return the list of member Properties that are part of what gets stored to machine langauge for this opcode.
public GetArgumentDefs ( ) : IEnumerable
return IEnumerable

InitMachineCodeData() public static method

This is intended to be called once, during the mod's initialization, and never again. It builds the Dictionaries that look up the type of opcode given its string name or code.
public static InitMachineCodeData ( ) : void
return void

Opcode() protected method

protected Opcode ( ) : System
return System

PopStructureAssertEncapsulated() protected method

A utility function that will do the same as a cpu.PopStructureEncapsulated, but with an additional check to ensure the value atop the stack isn't the arg bottom marker.
protected PopStructureAssertEncapsulated ( ICpu cpu, bool barewordOkay = false ) : Structure
cpu ICpu
barewordOkay bool
return Structure

PopValueAssert() protected method

A utility function that will do a cpu.PopValue, but with an additional check to ensure the value atop the stack isn't the arg bottom marker.
protected PopValueAssert ( ICpu cpu, bool barewordOkay = false ) : object
cpu ICpu
barewordOkay bool
return object

PopValueAssertEncapsulated() protected method

A utility function that will do the same as a cpu.PopValueEncapsulated, but with an additional check to ensure the value atop the stack isn't the arg bottom marker.
protected PopValueAssertEncapsulated ( ICpu cpu, bool barewordOkay = false ) : object
cpu ICpu
barewordOkay bool
return object

PopulateFromMLFields() public method

Starting from an empty instance of this opcode that you can assume was created from the default constructor, populate the Opcode's properties from a list of all the [MLFields] saved to the machine language file.
This needs to be overridden only if your Opcode has declared [MLField]'s. If your Opcode has no [MLFields] then the generic base version of this method works well enough.

TODO: Perhaps add an assert to the Init methods that will throw up a NagMessage if it detects an Opcode has be defined which has [MLFields] but lacks an override of this method.
public PopulateFromMLFields ( List fields ) : void
fields List A list of all the [MLFields] to populate the opcode with, /// given *IN ORDER* of their Ordering fields. This is important. If the /// opcode has 2 properties, one that was given attribute [MLField(10)] and the /// other that was given attribute [MLField(20)], then the one with ordering=10 /// will be the first one in this list, and the one with ordering=20 will be the /// second. You can process the list in the guaranteed assumption that the caller /// ordered the arguments this way.
/// NOTE: If the opcode has no MLField's attributes, then this may be passed in /// as null, rather than as a list of 0 items.
///
return void

ToString() public method

public ToString ( ) : string
return string

TypeFromCode() public static method

Given a string value of Code, find the Opcode Type that uses that as its CodeName.
public static TypeFromCode ( ByteCode code ) : Type
code ByteCode ByteCode to look up
return System.Type

TypeFromName() public static method

Given a string value of Name, find the Opcode Type that uses that as its Name.
public static TypeFromName ( string name ) : Type
name string name to look up
return System.Type

Property Details

SourcePath public_oe property

public GlobalPath,kOS.Safe.Persistence SourcePath
return kOS.Safe.Persistence.GlobalPath