コード例 #1
0
        public override IValue interpret(Context context)
        {
            // TODO synchronize
            ConcreteInstance instance        = context.loadSingleton(type);
            Context          instanceContext = context.newInstanceContext(instance, true);
            Context          childContext    = instanceContext.newChildContext();

            return(statements.interpret(childContext));
        }
コード例 #2
0
        private IValue interpretItemIteratorNoIndex(Context context, IType elemType)
        {
            IValue src = source.interpret(context);
            IEnumerator <IValue> iterator = getEnumerator(context, src);

            while (iterator.MoveNext())
            {
                Context child = context.newChildContext();
                child.registerValue(new Variable(v1, elemType));
                child.setValue(v1, iterator.Current);
                IValue value = statements.interpret(child);
                if (value == BreakResult.Instance)
                {
                    break;
                }
                if (value != null)
                {
                    return(value);
                }
            }
            return(null);
        }
コード例 #3
0
        public override IValue interpret(Context context)
        {
            IType  type   = resolveAndCheck(context);
            IValue result = resolved.interpret(context);

            context = context.newChildContext();
            if (resultName != null)
            {
                context.registerValue(new Variable(resultName, type));
                context.setValue(resultName, result);
            }
            andThen.interpret(context);
            return(VoidResult.Instance);
        }
コード例 #4
0
 public IValue interpret(Context context)
 {
     while (interpretCondition(context))
     {
         Context child = context.newChildContext();
         IValue  value = statements.interpret(child);
         if (value == BreakResult.Instance)
         {
             break;
         }
         if (value != null)
         {
             return(value);
         }
     }
     return(null);
 }
コード例 #5
0
 public IValue interpret(Context context)
 {
     context = context.newResourceContext();
     try
     {
         resource.interpret(context);
         return(statements.interpret(context));
     }
     finally
     {
         IValue res = context.getValue(resource.getName());
         if (res is IResource)
         {
             ((IResource)res).close();
         }
     }
 }
コード例 #6
0
 protected IValue evaluateSwitch(Context context, Object switchValue, ExecutionError toThrow)
 {
     foreach (SwitchCase sc in switchCases)
     {
         if (sc.matches(context, switchValue))
         {
             return(sc.interpret(context));
         }
     }
     if (defaultCase != null)
     {
         return(defaultCase.interpret(context));
     }
     if (toThrow != null)
     {
         throw toThrow;
     }
     return(null);
 }
コード例 #7
0
        public override IValue interpret(Context context)
        {
            List <object> toDelete = null;

            if (deletables != null)
            {
                toDelete = new List <object>();
                deletables.ForEach((exp) => CollectDeletables(context, exp, toDelete));
            }
            List <IStorable> toStore = null;

            if (storables != null)
            {
                toStore = new List <IStorable>();
                storables.ForEach((exp) => CollectStorables(context, exp, toStore));
            }
            if (deletables != null || storables != null)
            {
                IAuditMetadata withMeta = null;
                if (metadata != null)
                {
                    IValue value = metadata.interpret(context);
                    if (value is DocumentValue)
                    {
                        DocumentValue doc = (DocumentValue)value;
                        withMeta = DataStore.Instance.NewAuditMetadata();
                        foreach (String name in doc.GetMemberNames())
                        {
                            value          = doc.GetMemberValue(context, name, false);
                            withMeta[name] = value.GetStorableData();
                        }
                    }
                }
                DataStore.Instance.DeleteAndStore(toDelete, toStore, withMeta);
            }
            if (andThen != null)
            {
                andThen.interpret(context);
            }
            return(null);
        }
コード例 #8
0
        public override IValue interpret(Context context)
        {
            IValue result = null;

            try
            {
                result = statements.interpret(context);
            }
            catch (ExecutionError e)
            {
                IValue switchValue = populateError(e, context);
                result = evaluateSwitch(context, switchValue, e);
            }
            finally
            {
                if (alwaysStatements != null)
                {
                    alwaysStatements.interpret(context);
                }
            }
            return(result);
        }
コード例 #9
0
 public IValue interpret(Context context)
 {
     context = downCast(context, true);
     return(statements.interpret(context));
 }
コード例 #10
0
 public IValue interpret(Context context)
 {
     return(statements.interpret(context));
 }