示例#1
0
		}//Binary
		
		protected override void Unary( Opcode op, byte[] code, ref int at )
		{
			var paren = Parens;
			if( paren )
			{
				Write( '(' );
			}
			var text = op.Text();
			var post = op.Postfix();
			if( !post )
			{
				Write( text );
				if( text.Length > 2 )
				{
					Write( ' ' );
				}
			}
			Expression( code, ref at );
			if( post )
			{
				Write( text );
			}
			if( paren )
			{
				Write( ')' );
			}
		}//Unary
示例#2
0
		}//Literal
		
		protected override void Binary( Opcode op, byte[] code, ref int at )
		{
			var paren = Parens;
			if( paren )
			{
				Write( '(' );
			}
			if( op == Opcode.Cast )
			{
				Typeref( code, ref at );
				Write( "! " );
				Expression( code, ref at );
				if( paren )
				{
					Write( ')' );
				}
				return;
			}
			Expression( code, ref at );
			Write( ' ' );
			Write( op.Text() );
			Write( ' ' );
			if( (op == Opcode.LogicAnd) || (op == Opcode.LogicOr) )
			{
				at += 4;
			}
			Expression( code, ref at );
			if( paren )
			{
				Write( ')' );
			}
		}//Binary
示例#3
0
		protected override void Literal( Opcode op, byte[] code, ref int at )
		{
			if( op < Opcode.Ident )
			{
				Write( op.Text() );
				return;
			}
			if( (op == Opcode.Ident) || (op == Opcode.Number) )
			{
				var n = code[at++];
				Write( Encoding.UTF8.GetString( code, at, n ) );
				at += n;
				return;
			}
			if( op == Opcode.String )
			{
				var n = Cint( code, ref at );
				Write( Encoding.UTF8.GetString( code, at, n ) );
				at += n;
				return;
			}
			throw new InvalidOperationException();
		}//Literal
示例#4
0
		}//Create
		
		public Value Get( Opcode op )
		{
			return op == Opcode.Null ? new Value( this.Object ) : Get( op.Text() );
		}//Get
示例#5
0
		protected override void Other( Opcode op, byte[] code, ref int at )
		{
			switch( op )
			{
			default:
				throw new NotImplementedException();
			case Opcode.Import:
				Write( "using " );
				Write( Unalias( Cident( code, ref at ), false, true ) );
				return;
			case Opcode.Space:
				if( Space != null )
				{
					Indent--;
					Line();
					Write( "}" );
				}
				if( code[at] == 0 )
				{
					at++;
					Space = null;
					return;
				}
				Write( "namespace " );
				Write( Space = Unalias( Cident( code, ref at ), false, true ) );
				Line();
				Write( "{" );
				Indent++;
				Line();
				return;
			case Opcode.Class:
			case Opcode.Struct:
			case Opcode.Enum:
			case Opcode.Face:
				var size = Cint( code, ref at );
				var body = at + size;
				var tflags = ((Tflag)Cushort( code, ref at ));
				var gtnum = code[at++];
				var bcnum = code[at++];
				var access = tflags.AccessText() ?? DefClassAccess.AccessText();
				if( access != null )
				{
					Write( access );
					Write( ' ' );
				}
				var scope = tflags.ScopeText();
				if( scope != null )
				{
					Write( scope );
					Write( ' ' );
				}
				if( (tflags & Tflag.Hide) != 0 )
				{
					Write( "new " );
				}
				if( (tflags & Tflag.Unsafe) != 0 )
				{
					Write( "unsafe " );
				}
				if( (tflags & Tflag.Partial) != 0 )
				{
					Write( "partial " );
				}
				Write( op.Text() );
				Write( ' ' );
				Write( Unalias( Cident( code, ref at ), false, true ) );
				if( gtnum != 0 )
				{
					throw new NotImplementedException();
				}
				if( bcnum != 0 )
				{
					var first = true;
					do
					{
						Write( first ? ": " : ", " );
						first = false;
						Typeref( code, ref at );
					}
					while( (--bcnum) > 0 );
				}
				Debug.Assert( at == body );
				at = body;
				Block( code, ref at );
				return;
			case Opcode.Field:
			case Opcode.Event:
				size = Cint( code, ref at );
				tflags = ((Tflag)Cushort( code, ref at ));
				access = tflags.AccessText();
				if( access != null )
				{
					Write( access );
					Write( ' ' );
				}
				scope = tflags.ScopeText();
				if( scope != null )
				{
					Write( scope );
					Write( ' ' );
				}
				if( op == Opcode.Event )
				{
					Write( "event " );
				}
				var s = Unalias( Cident( code, ref at ) );
				if( code[at] == 0 )
				{
					at++;
					Write( s );
				}
				else
				{
					Typeref( code, ref at );
				}
				Write( ' ' );
				Write( s );
				if( code[at] == 0 )
				{
					at++;
				}
				else
				{
					Write( " = " );
					Expression( code, ref at );
				}
				return;
			case Opcode.Func:
				PushLocal();
				size = Cint( code, ref at );
				body = at + size;
				tflags = ((Tflag)Cushort( code, ref at ));
				access = tflags.AccessText() ?? DefMethodAccess.AccessText();
				if( access != null )
				{
					Write( access );
					Write( ' ' );
				}
				scope = tflags.ScopeText();
				if( scope != null )
				{
					Write( scope );
					Write( ' ' );
				}
				if( (tflags & Tflag.Hide) != 0 )
				{
					Write( "new " );
				}
				if( (tflags & Tflag.Unsafe) != 0 )
				{
					Write( "unsafe " );
				}
				var argc = code[at++];
				s = Unalias( Cident( code, ref at ) );
				size = Cint( code, ref at );
				var args = at + size;
				if( (size == 0) || (code[at] == 0) )
				{
					Write( "void" );
				}
				else
				{
					Typeref( code, ref at );
				}
				Write( ' ' );
				Write( s );
				Write( '(' );
				Debug.Assert( (at == args) || ((size == 1) && (code[at] == 0)) );
				at = args;
				for( var i = 0; i < argc; i++ )
				{
					size = Cint( code, ref at );
					var narg = at + size;
					if( i > 0 )
					{
						Write( ", " );
					}
					s = Cident( code, ref at );
					AddLocal( s );
					size = Cint( code, ref at );
					var vat = at + size;
					if( (size == 0) || (code[at] == 0) )
					{
						Write( Unalias( s ) );
					}
					else
					{
						Typeref( code, ref at );
					}
					Write( ' ' );
					Write( s );
					Debug.Assert( (at == vat) || ((size == 1) && (code[at] == 0)) );
					at = vat;
					size = Cint( code, ref at );
					if( (size != 0) && (code[at] != 0) )
					{
						Write( " = " );
						Expression( code, ref at );
					}
					Debug.Assert( (at == narg) || ((size == 1) && (code[at] == 0)) );
					at = narg;
				}
				Write( ')' );
				Debug.Assert( at == body );
				at = body;
				Block( code, ref at );
				PopLocal();
				return;
			}
		}//Other