private FunctionParameter(ExpressionReadMode readMode, string name, INameReference typeName, Variadic variadic, IExpression defaultValue, EntityModifier modifier, bool isNameRequired) { this.UsageMode = readMode; this.Modifier = modifier ?? EntityModifier.None; this.Name = NameDefinition.Create(name); this.IsNameRequired = isNameRequired; this.Variadic = variadic; this.ElementTypeName = typeName; if (this.IsVariadic) { this.TypeName = NameFactory.ReferenceNameReference(NameFactory.ISequenceNameReference(this.ElementTypeName, mutability: TypeMutability.ForceMutable)); } else { this.TypeName = this.ElementTypeName; } this.defaultValue = defaultValue; this.instancesCache = new EntityInstanceCache(this, () => GetInstance(TypeMutability.None, TemplateTranslation.CreateParameterless(this), Lifetime.Timeless)); this.attachPostConstructor(); }
public static FunctionBuilder CreateDeclaration( string name, ExpressionReadMode callMode, INameReference result) { return(Create(name, callMode, result, (Block)null)); }
private static Block constructor(ExpressionReadMode readMode, Func <Block, ExpressionReadMode> readModeCalc, IEnumerable <IExpression> instructions) { List <IExpression> body = (instructions ?? Enumerable.Empty <IExpression>()).ToList(); return(new Block(readMode, readModeCalc, body)); }
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)); }
protected Literal(string inputValue, NameReference typeName, ExpressionReadMode readMode = ExpressionReadMode.ReadRequired) : base(readMode) { this.typeName = typeName; this.InputValue = inputValue; this.attachPostConstructor(); }
private Block(ExpressionReadMode readMode, Func <Block, ExpressionReadMode> readModeCalc, List <IExpression> body) : base(readModeCalc == null ? new Option <ExpressionReadMode>(readMode) : new Option <ExpressionReadMode>()) { this.instructions = body; this.readModeCalc = readModeCalc; this.attachPostConstructor(); }
public static FunctionParameter Create(string name, INameReference typeName, Variadic variadic, IExpression defaultValue, bool isNameRequired = false, ExpressionReadMode usageMode = ExpressionReadMode.ReadRequired) { return(new FunctionParameter(usageMode, name, typeName, variadic, defaultValue, null, isNameRequired: isNameRequired)); }
public static FunctionBuilder Create( string name, IEnumerable <TemplateParameter> nameParameters, ExpressionReadMode callMode, INameReference result, Block body) { return(new FunctionBuilder(name, nameParameters, null, callMode, result, body)); }
protected void setReadMode(ExpressionReadMode readMode) { if (this.isReadModeSet) { throw new Exception(); } this.readMode = new Option <ExpressionReadMode>(readMode); }
private VariableBuilder(ExpressionReadMode readMode, string name, INameReference typeName, IExpression initValue) { this.name = name; this.readMode = readMode; this.typeName = typeName; this.initValue = initValue; }
public static FunctionBuilder Create( string name, ExpressionReadMode callMode, INameReference result, Block body) { return(new FunctionBuilder(name, null, null, callMode, result, body)); }
private static IExpression create(ExpressionReadMode readMode, IExpression lhs, IExpression rhsValue, bool isPostInitialization) { if (lhs is FunctionCall call && call.IsIndexer) { if (readMode != ExpressionReadMode.CannotBeRead) { throw new NotImplementedException(); } return(call.ConvertIndexerIntoSetter(rhsValue)); }
public static FunctionBuilder CreateDeclaration( string name, string nameParameter, VarianceMode variance, ExpressionReadMode callMode, INameReference result) { return(new FunctionBuilder(name, TemplateParametersBuffer.Create(variance, nameParameter).Values, null, callMode, result, (Block)null)); }
public static FunctionDefinition CreateFunction( EntityModifier modifier, NameDefinition name, IEnumerable <TemplateConstraint> constraints, IEnumerable <FunctionParameter> parameters, ExpressionReadMode callMode, INameReference result, Block body) { return(new FunctionDefinition(modifier, name, (NameDefinition)null, constraints, parameters, callMode, result, constructorChainCall: null, body: body, includes: null, friends: null)); }
private FunctionBuilder( string name, IEnumerable <TemplateParameter> nameParameters, IEnumerable <FunctionParameter> parameters, ExpressionReadMode callMode, INameReference result, Block body) { this.name = name; this.nameParameters = (nameParameters ?? Enumerable.Empty <TemplateParameter>()).StoreReadOnly(); this.parameters = parameters; this.callMode = callMode; this.result = result; this.body = body; }
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}"); } }
public static FunctionParameter Create(string name, INameReference typeName, EntityModifier modifier, ExpressionReadMode usageMode = ExpressionReadMode.ReadRequired) { return(new FunctionParameter(usageMode, name, typeName, Variadic.None, null, modifier, isNameRequired: false)); }
public static Block Create(ExpressionReadMode readMode, IEnumerable <IExpression> body) { return(constructor(readMode, null, body)); }
public static VariableDeclaration Create(ExpressionReadMode readMode, string name, INameReference typeName, IExpression initValue, EntityModifier modifier, IEnumerable <LabelReference> friends) { return(new VariableDeclaration(modifier, readMode, name, typeName, initValue, friends)); }
protected Expression(ExpressionReadMode readMode) : this(new Option <ExpressionReadMode>(readMode)) { }
public static NameReference Create(IExpression prefix, BrowseMode browse, string name, ExpressionReadMode readMode, params INameReference[] arguments) { return(new NameReference(TypeMutability.None, prefix, browse, null, name, arguments.Select(it => new TemplateArgument(it)), readMode, isRoot: false)); }