Example #1
0
 internal ArgumentData(string name, IReadOnlyType type, IReadOnlyFunction owner, Preposition prep)
 {
     this.Name = name;
     this.Type = type;
     this.Owner = owner;
     this.AlternateAccess = prep;
 }
Example #2
0
        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;
        }
Example #3
0
        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;
        }
Example #4
0
        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;
        }
Example #5
0
        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);
        }
Example #6
0
        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("}");
        }
Example #7
0
        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;
        }
Example #8
0
 internal VariableData(string name, IReadOnlyType type, IReadOnlyContext owner)
 {
     this.Name = name;
     this.Type = type;
     this.OwningContext = owner;
 }
Example #9
0
 internal ArgumentData(string name, IReadOnlyType type, IReadOnlyFunction owner)
     : this(name, type, owner, Preposition.NONE)
 {
 }
Example #10
0
 private static void RegisterType(IReadOnlyType type)
 {
     dataMapping[type.Name] = type;
 }
Example #11
0
 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);
 }
Example #13
0
        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;
        }
Example #14
0
        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);
 }
Example #17
0
 public Constant(IReadOnlyType type, string value)
 {
     this.Type = type;
     this.Value = value;
 }