C# Class WhiteCore.ScriptEngine.DotNetEngine.CompilerTools.CSCodeGenerator

Inheritance: IDisposable
显示文件 Open project: WhiteCoreSim/WhiteCore-Dev

Public Properties

Property Type Description
LocalMethodArguements ObjectList>.Dictionary
LocalMethods string>.Dictionary

Public Methods

Method Description
CSCodeGenerator ( WhiteCore.ScriptEngine.DotNetEngine.CompilerTools.Compiler compiler ) : System

Creates an 'empty' CSCodeGenerator instance.

Convert ( string script ) : string

Generate the code from the AST we have.

CreateCompilerScript ( WhiteCore.ScriptEngine.DotNetEngine.CompilerTools.Compiler compiler, List MethodsToAdd, string ScriptClass ) : string
Dispose ( ) : void
GetHeaderCount ( WhiteCore.ScriptEngine.DotNetEngine.CompilerTools.Compiler compiler ) : int

Private Methods

Method Description
AddWarning ( string warning ) : void
CheckEvent ( string script, string state ) : void
CheckEventCasts ( string script ) : void

Checks the C# script for the correct casts in events This stops errors from misformed events ex. 'touch(vector3 position)' instead of 'touch(int touch)'

CheckFloatExponent ( string script ) : string
CheckForInlineVectors ( string script ) : string
CheckIfGlobalVariable ( string varName, string type, SYMBOL kid ) : string
CheckName ( string s ) : string

Returns the passed name with an underscore prepended if that name is a reserved word in C# and not reserved in LSL otherwise it just returns the passed name. This makes no attempt to cache the results to minimise future lookups. For a non trivial scripts the number of unique identifiers could easily grow to the size of the reserved word list so maintaining a list or dictionary and doing the lookup there firstwould probably not give any real speed advantage. I believe there is a class Microsoft.CSharp.CSharpCodeProvider that has a function CreateValidIdentifier(str) that will return either the value of str if it is not a C# key word or "_"+str if it is. But availability under Mono?

DumpAfterFunc ( bool marc ) : string
DumpFunc ( bool marc ) : string
FindLineNumbers ( string EventName, string Problem ) : void
FindWrongParameterCountLineNumbers ( string EventName, int correct, int i ) : void
FixAdditionalEvents ( string script ) : string
FuncCallsMarc ( ) : bool
Generate ( string s ) : string

Prints text.

Generate ( string s, SYMBOL sym ) : string

Prints text.

GenerateArgumentDeclarationList ( ScriptEngineParser.ArgumentDeclarationList adl ) : string

Generates the code for an ArgumentDeclarationList node.

GenerateArgumentList ( ScriptEngineParser.ArgumentList al ) : string

Generates the code for an ArgumentList node.

GenerateAssignment ( ScriptEngineParser.Assignment a ) : string

Generates the code for an Assignment node.

GenerateBinaryExpression ( ScriptEngineParser.BinaryExpression be, bool isUnaryExpression, string addition ) : string

Generates the code for a BinaryExpression node.

GenerateCompoundStatement ( ScriptEngineParser.CompoundStatement cs ) : string

Generates the code for a CompoundStatement node.

GenerateConstant ( ScriptEngineParser.Constant c ) : string

Generates the code for a Constant node.

GenerateDeclaration ( ScriptEngineParser.Declaration d ) : string

Generates the code for a Declaration node.

GenerateDoWhileStatement ( ScriptEngineParser.DoWhileStatement dws ) : string

Generates the code for a DoWhileStatement node.

GenerateFireEventMethod ( ) : string
GenerateForLoop ( ScriptEngineParser.ForLoop fl ) : string

Generates the code for a ForLoop node.

GenerateForLoopStatement ( ScriptEngineParser.ForLoopStatement fls ) : string

Generates the code for a ForLoopStatement node.

GenerateFunctionCall ( ScriptEngineParser.FunctionCall fc, bool NeedRetVal ) : string

Generates the code for a FunctionCall node.

GenerateGlobalFunctionDefinition ( ScriptEngineParser.GlobalFunctionDefinition gf ) : string

Generates the code for a GlobalFunctionDefinition node.

GenerateGlobalVariableDeclaration ( ScriptEngineParser.GlobalVariableDeclaration gv ) : string

Generates the code for a GlobalVariableDeclaration node.

GenerateIfStatement ( ScriptEngineParser.IfStatement ifs ) : string

Generates the code for an IfStatement node.

GenerateIncrementDecrementExpression ( ScriptEngineParser.IncrementDecrementExpression ide ) : string

Generates the code for a IncrementDecrementExpression node.

GenerateIndented ( string s, SYMBOL sym ) : string

Prints text correctly indented.

GenerateIndentedLine ( string s ) : string

Prints text correctly indented, followed by a newline.

GenerateIndentedLine ( string s, SYMBOL sym ) : string

Prints text correctly indented, followed by a newline.

GenerateJumpLabel ( ScriptEngineParser.JumpLabel jl ) : string

Generates the code for a JumpLabel node.

GenerateJumpStatement ( ScriptEngineParser.JumpStatement js ) : string

Generates the code for a JumpStatement node.

GenerateLine ( ) : string

Prints a newline.

GenerateLine ( string s ) : string

Prints text, followed by a newline.

GenerateLine ( string s, SYMBOL sym ) : string

Prints text, followed by a newline.

GenerateListConstant ( ScriptEngineParser.ListConstant lc ) : string

Generates the code for a ListConstant node.

GenerateNode ( SYMBOL s ) : string

Recursively called to generate each type of node. Will generate this node, then all it's children.

GenerateParenthesisExpression ( ScriptEngineParser.ParenthesisExpression pe ) : string

Generates the code for a ParenthesisExpression node.

GenerateReturnStatement ( ScriptEngineParser.ReturnStatement rs ) : string

Generates the code for a ReturnStatement node.

GenerateRotationConstant ( ScriptEngineParser.RotationConstant rc ) : string

Generates the code for a RotationConstant node.

GenerateState ( ScriptEngineParser.State s ) : string

Generates the code for a State node.

GenerateStateChange ( ScriptEngineParser.StateChange sc ) : string

Generates the code for a StateChange node.

GenerateStateEvent ( ScriptEngineParser.StateEvent se, string parentStateName ) : string

Generates the code for a StateEvent node.

GenerateStatement ( ScriptEngineParser.Statement s ) : string

Generates the code for a Statement node.

GenerateTypecastExpression ( ScriptEngineParser.TypecastExpression te ) : string

Generates the code for a TypecastExpression node.

GenerateUnaryExpression ( ScriptEngineParser.UnaryExpression ue ) : string

Generates the code for a UnaryExpression node.

GenerateVectorConstant ( ScriptEngineParser.VectorConstant vc ) : string

Generates the code for a VectorConstant node.

GenerateWhileStatement ( ScriptEngineParser.WhileStatement ws ) : string

Generates the code for a WhileStatement node.

GetLocalDeclarationKey ( ) : string
GetValue ( ScriptEngineParser.Constant identEx ) : string
Indent ( ) : string

Prints correct indentation.

ResetCounters ( ) : void

Resets various counters and metadata.

checkForMultipleAssignments ( List identifiers, SYMBOL s ) : void

Method Details

CSCodeGenerator() public method

Creates an 'empty' CSCodeGenerator instance.
public CSCodeGenerator ( WhiteCore.ScriptEngine.DotNetEngine.CompilerTools.Compiler compiler ) : System
compiler WhiteCore.ScriptEngine.DotNetEngine.CompilerTools.Compiler
return System

Convert() public method

Generate the code from the AST we have.
public Convert ( string script ) : string
script string The LSL source as a string.
return string

CreateCompilerScript() public static method

public static CreateCompilerScript ( WhiteCore.ScriptEngine.DotNetEngine.CompilerTools.Compiler compiler, List MethodsToAdd, string ScriptClass ) : string
compiler WhiteCore.ScriptEngine.DotNetEngine.CompilerTools.Compiler
MethodsToAdd List
ScriptClass string
return string

Dispose() public method

public Dispose ( ) : void
return void

GetHeaderCount() public static method

public static GetHeaderCount ( WhiteCore.ScriptEngine.DotNetEngine.CompilerTools.Compiler compiler ) : int
compiler WhiteCore.ScriptEngine.DotNetEngine.CompilerTools.Compiler
return int

Property Details

LocalMethodArguements public_oe property

public Dictionary LocalMethodArguements
return ObjectList>.Dictionary

LocalMethods public_oe property

public Dictionary LocalMethods
return string>.Dictionary