예제 #1
0
        /// <summary>
        /// Generate action and condition (possibly) for the currently defined emitter
        /// </summary>
        /// <param name="emitter"></param>
        private void CompileBody(Emitter.Emitter emitter)
        {
            // compile action
              emitter.CurrentMethod = emitter.FindMethod(PlannerID, "Action", "flow[]", "symbol");
              emitter.MakeMethodVirtual(emitter.CurrentMethod);

              LoadClosuredVariables(Closures, emitter);

              emitter.EmitLoadParameter(0);
              emitter.EmitLoadParameter(1);
              Action.Compile(emitter);

              // append the arguments to the user
              emitter.EmitReturn();
        }
예제 #2
0
        public override void Compile(Emitter.Emitter emitter)
        {
            try
              {
            Resolve(emitter);
              }
              catch (CompilerException ex)
              {
            ex.AffixToLexem(Lexem);
            throw;
              }

              switch (Kind)
              {

            case IdentifierKind.StaticField:    emitter.EmitLoadField(emitter.FindField(OwnerType, Name)); break;

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

            case IdentifierKind.StaticMethod:   emitter.EmitCall(emitter.FindMethod(OwnerType, Name)); break;

            case IdentifierKind.Method:         if (ExpressionPrefix != null)
                                              ExpressionPrefix.Compile(emitter);
                                            else
                                              emitter.EmitLoadThis();
                                            emitter.EmitCall(emitter.FindMethod(OwnerType, Name)); break;

            case IdentifierKind.Variable:       emitter.EmitLoadVariable(emitter.CurrentMethod.Scope.Find(Name)); break;

            case IdentifierKind.Parameter:      emitter.EmitLoadParameter(emitter.CurrentMethod.Parameters[Name].Id); break;

            case IdentifierKind.SizeProperty:   ExpressionPrefix.Compile(emitter);
                                            emitter.EmitLoadArraySize(); break;
              }
        }