Beispiel #1
0
        public override void Compile(Emitter.Emitter emitter)
        {
            try
              {
            Resolve(emitter);

            if (!emitter.TypeIsParent(IdentifierType, Expression.GetExpressionType(emitter)))
              Error(String.Format(Resources.errAssignTypeMismatch, Expression.GetExpressionType(emitter), IdentifierType));
              }
              catch(CompilerException ex)
              {
            ex.AffixToLexem(Lexem);
            throw;
              }

              switch (Kind)
              {

            case IdentifierKind.StaticField:  Expression.Compile(emitter);
                                          emitter.EmitSaveField(emitter.FindField(OwnerType, Name)); break;

            case IdentifierKind.Field:        if (ExpressionPrefix != null)
                                            ExpressionPrefix.Compile(emitter);
                                          else
                                            emitter.EmitLoadThis();
                                          Expression.Compile(emitter);
                                          emitter.EmitSaveField(emitter.FindField(OwnerType, Name)); break;

            case IdentifierKind.Variable:     Expression.Compile(emitter);
                                          emitter.EmitSaveVariable(emitter.CurrentMethod.Scope.Find(Name)); break;

            case IdentifierKind.Parameter:    Expression.Compile(emitter);
                                          emitter.EmitSaveParameter(emitter.CurrentMethod.Parameters[Name].Id); break;
              }
        }