internal ArgumentData(string name, IReadOnlyType type, IReadOnlyFunction owner, Preposition prep) { this.Name = name; this.Type = type; this.Owner = owner; this.AlternateAccess = prep; }
public IReadOnlyVariable AddVariable(string name, IReadOnlyType type) { if (ContainsVariable(name)) throw new InvalidOperationException("The variable already exists in this context."); VariableData data = new VariableData(name, type, this); variablesByName[name] = data; return data; }
public IFunctionData CreateFunction(string name, IReadOnlyType returnType) { if (funcNames.Contains(name)) throw new InvalidOperationException("A function with the given name already exists."); FunctionData data = new FunctionData(name, this, returnType); this.functions.Add(data); this.funcNames.Add(name); return data; }
public IReadOnlyVariable AddVariable(string name, IReadOnlyType type) { if (ContainsVariable(name)) throw new InvalidOperationException("The variable already exists."); var newVar = new VariableData(name, type, this); variables[name] = newVar; return newVar; }
internal FunctionData(string name, IReadOnlyType owner, IReadOnlyType returnType) { this.Name = name; this.Owner = owner; this.ReturnType = returnType; functionContext = new ContextData(owner.ClassContext); arguments = new List<IReadOnlyArgument>(); prepArgMap = new Dictionary<Preposition, IReadOnlyArgument>(); argumentNames = new HashSet<string>(); expressions = new ExpressionSet(functionContext); }
private void PrintClass(IReadOnlyType type) { //TODO: make a static class and an internal class AppendFormatLine("public class {0}", type.Name); AppendLine("{"); indentLevel++; foreach (IReadOnlyFunction function in type.MemberFunctions) { PrintFunction(function); } indentLevel--; AppendLine("}"); }
public IDeclaration SetAsDeclaration(string variableName, IReadOnlyType type, out IReadOnlyVariable variableCreated) { if (ComponentsHead != null) throw new InvalidOperationException("The expression has already been set! It cannot be set twice."); if (variableName == null || type == null) throw new ArgumentNullException(); if (owningContext.ContainsVariable(variableName)) throw new InvalidOperationException("A variable with that name already exists!"); variableCreated = owningContext.AddVariable(variableName, type); Declaration declaration = new Declaration(variableName, type); this.ComponentsHead = declaration; return declaration; }
internal VariableData(string name, IReadOnlyType type, IReadOnlyContext owner) { this.Name = name; this.Type = type; this.OwningContext = owner; }
internal ArgumentData(string name, IReadOnlyType type, IReadOnlyFunction owner) : this(name, type, owner, Preposition.NONE) { }
private static void RegisterType(IReadOnlyType type) { dataMapping[type.Name] = type; }
public Declaration(string variableName, IReadOnlyType type) { this.Name = variableName; this.Type = type; }
public static IConstant CreateConstant(IReadOnlyType type, string value) { return new Constant(type, value); }
public IReadOnlyArgument CreateAlternateArgument(string name, IReadOnlyType type, Preposition alternateAccess) { if (this.argumentNames.Contains(name)) throw new InvalidOperationException("An argument with the given name already exists."); if (this.prepArgMap.ContainsKey(alternateAccess)) throw new InvalidOperationException("An argument already exists with the given alternate access."); ArgumentData arg = new ArgumentData(name, type, this, alternateAccess); this.arguments.Add(arg); this.argumentNames.Add(name); this.prepArgMap[alternateAccess] = arg; return arg; }
public IReadOnlyArgument CreateArgument(string name, IReadOnlyType type) { if (this.argumentNames.Contains(name)) throw new InvalidOperationException("An argument with the given name already exists."); ArgumentData arg = new ArgumentData(name, type, this); this.arguments.Add(arg); this.argumentNames.Add(name); return arg; }
public void Setup() { type = KnownTypes.Int; expression = CreationUtilities.CreateExpression(); declaration = expression.SetAsDeclaration(VarName, type, out createdVar); }
public static IFunctionData CreateFunction(IReadOnlyType returnType) { return CreateType().CreateFunction("MyFunc", returnType); }
public Constant(IReadOnlyType type, string value) { this.Type = type; this.Value = value; }