Exemplo n.º 1
0
        private VariableDeclaration(EntityModifier modifier, ExpressionReadMode readMode, string name,
                                    INameReference typeName,
                                    IExpression initValue,
                                    IEnumerable <LabelReference> friends = null)
            : base(readMode)
        {
            if (name == null)
            {
                throw new ArgumentNullException();
            }

            this.Modifier     = modifier ?? EntityModifier.None;
            this.Name         = NameDefinition.Create(name);
            this.TypeName     = typeName;
            this.initValue    = initValue;
            this.AccessGrants = (friends ?? Enumerable.Empty <LabelReference>()).StoreReadOnly();

            this.instancesCache = new EntityInstanceCache(this, () => GetInstance(TypeMutability.None,
                                                                                  TemplateTranslation.CreateParameterless(this), Lifetime.Timeless));

            this.closures = new List <TypeDefinition>();

            this.attachPostConstructor();

            this.flow = Later.Create(() => ExecutionFlow.CreatePath(InitValue));
        }
Exemplo n.º 2
0
        private Spread(IExpression expr)
            : base(ExpressionReadMode.ReadRequired)
        {
            this.expr = expr;

            this.attachPostConstructor();

            this.flow = Later.Create(() => ExecutionFlow.CreatePath(Expr));
        }
Exemplo n.º 3
0
        private Chain(IEnumerable <IExpression> instructions)
            : base(ExpressionReadMode.ReadRequired)
        {
            this.Instructions = instructions.StoreReadOnly();

            this.attachPostConstructor();

            this.flow = Later.Create(() => ExecutionFlow.CreatePath(this.Instructions));
        }
Exemplo n.º 4
0
        private ReinterpretType(IExpression lhs, INameReference rhsTypeName)
            : base(ExpressionReadMode.ReadRequired)
        {
            this.Lhs         = lhs;
            this.RhsTypeName = rhsTypeName;

            this.attachPostConstructor();

            this.flow = Later.Create(() => ExecutionFlow.CreatePath(Lhs));
        }
Exemplo n.º 5
0
        private IsSame(IExpression lhs, IExpression rhs)
            : base(ExpressionReadMode.ReadRequired)
        {
            this.Lhs = lhs;
            this.Rhs = rhs;

            this.attachPostConstructor();

            this.flow = Later.Create(() => ExecutionFlow.CreatePath(Lhs, Rhs));
        }
Exemplo n.º 6
0
        private FunctionArgument(string nameLabel, IExpression expression)
            : base()
        {
            this.NameLabel  = nameLabel;
            this.expression = expression;

            this.closures = new List <TypeDefinition>();

            this.attachPostConstructor();

            this.flow = Later.Create(() => ExecutionFlow.CreatePath(Expression));
        }
Exemplo n.º 7
0
        private FunctionCall(CallMode mode,
                             IExpression callee, IEnumerable <FunctionArgument> arguments, NameReference requestedOutcomeType)
            : base()
        {
            this.mode                     = mode;
            this.callee                   = callee;
            this.UserArguments            = (arguments ?? Enumerable.Empty <FunctionArgument>()).Indexed().StoreReadOnlyList();
            this.RequestedOutcomeTypeName = requestedOutcomeType;

            this.closures = new List <TypeDefinition>();

            this.attachPostConstructor();

            this.flow = Later.Create(() => ExecutionFlow.CreatePath(UserArguments));
        }
Exemplo n.º 8
0
        private FunctionDefinition(EntityModifier modifier,
                                   NameDefinition name,
                                   NameDefinition label,
                                   IEnumerable <TemplateConstraint> constraints,
                                   IEnumerable <FunctionParameter> parameters,
                                   ExpressionReadMode callMode,
                                   INameReference result,
                                   FunctionCall constructorChainCall,
                                   Block body,
                                   IEnumerable <NameReference> includes,
                                   IEnumerable <LabelReference> friends)
            : base(modifier | (body == null ? EntityModifier.Abstract : EntityModifier.None), name, constraints, includes)
        {
            parameters = parameters ?? Enumerable.Empty <FunctionParameter>();

            this.Label        = label ?? NameDefinition.Create(name.Name);
            this.AccessGrants = (friends ?? Enumerable.Empty <LabelReference>()).StoreReadOnly();
            this.Parameters   = parameters.Indexed().StoreReadOnlyList();
            setResultParameter(result);
            this.IsResultTypeNameInfered = result == null;
            if (this.IsResultTypeNameInfered)
            {
                this.resultTypeCandidates = new List <IEntityInstance>();
            }
            this.UserBody = body;
            this.CallMode = callMode;

            // attaching zero-constructor call to the body of the function will be done when attaching entire function to a type
            if (constructorChainCall != null)
            {
                this.UserBody.SetConstructorChainCall(constructorChainCall);
            }

            if (this.IsLambdaInvoker)
            {
                this.LambdaTrap = new LambdaTrap();
            }

            this.attachPostConstructor();

            this.flow = Later.Create(() => ExecutionFlow.CreatePath(UserBody));
            this.constructionCompleted = true;

            if (!IsValidMutableName(this.Name.Name, this.Modifier))
            {
                throw new ArgumentException($"Mutable function has to be marked with name as well {this.Name}");
            }
        }
Exemplo n.º 9
0
        private IfBranch(IExpression condition, IEnumerable <IExpression> body, IfBranch next)
        {
            this.condition = condition;
            // we have to postpone calculating read-mode because the last instruction can be function call
            // and it is resolved only after finding its target
            if (!body.Any())
            {
                body = new[] { UnitLiteral.Create() }
            }
            ;
            this.Body = Block.Create((block) => block.Instructions.Last().ReadMode, body);
            this.Next = next;

            this.attachPostConstructor();

            this.flow = Later.Create(() => this.IsElse
                ? ExecutionFlow.CreateElse(Body, Next) : ExecutionFlow.CreateFork(Condition, Body, Next));
        }
Exemplo n.º 10
0
        private BoolOperator(OpMode mode, IExpression lhs, IExpression rhs)
            : base(ExpressionReadMode.ReadRequired)
        {
            this.Mode = mode;
            this.lhs  = lhs;
            this.rhs  = rhs;

            this.attachPostConstructor();

            this.flow = Later.Create(() =>
            {
                switch (this.Mode)
                {
                case OpMode.And: return(ExecutionFlow.CreateFork(Lhs, Rhs, null));

                case OpMode.Or: return(ExecutionFlow.CreateFork(Lhs, null, Rhs));

                default: throw new InvalidOperationException();
                }
            });
        }
 public UIDialogResult(ExecutionFlow execution, SendReport report)
 {
     this.Execution = execution;
     this.Report    = report;
 }
Exemplo n.º 12
0
		internal UIDialogResult(ExecutionFlow execution, SendReport report)
		{
			this.Execution = execution;
			this.Report = report;
		}
 public UIDialogResult(ExecutionFlow execution, bool sendReport)
 {
     Execution  = execution;
     SendReport = sendReport;
 }
Exemplo n.º 14
0
 public UIDialogResult(ExecutionFlow execution, bool sendReport)
 {
     Execution = execution;
     SendReport = sendReport;
 }
Exemplo n.º 15
0
 protected Expression(Option <ExpressionReadMode> readMode)
 {
     this.readMode = readMode;
     this.flow     = Later.Create(() => ExecutionFlow.CreatePath(ChildrenNodes.WhereType <IExpression>()));
 }