Ejemplo n.º 1
0
            public Impl(IDependencySystem system, Type returnType)
                : base(system)
            {
                var paramSymbol = new Symbol.Var(null, "path", Symbol.VarKind.Param);
                var stringType  = System.ReferToConstType("@c", "str");

                Type = new Type.Proc(true, new List <Type.Proc.Param> {
                    new Type.Proc.Param(paramSymbol, stringType)
                }, returnType);
                ReturnType = System.TypeTranslator.ToLirType(returnType);
            }
Ejemplo n.º 2
0
        public ImportIntrinsic(IDependencySystem system)
            : base(system)
        {
            var paramSymbol = new Symbol.Var(null, "path", Symbol.VarKind.Param);
            var stringType  = System.ReferToConstType("@c", "str");

            Type = new Type.Proc(true, new List <Type.Proc.Param> {
                new Type.Proc.Param(paramSymbol, stringType)
            }, Type.Type_);
            ReturnType = Lir.Types.Type.User_;
        }
Ejemplo n.º 3
0
            public Undependent(IDependencySystem system)
                : base(system)
            {
                // TODO: Ease building these?
                var typeParamSymbol = new Symbol.Var(null, "T", Symbol.VarKind.Param);

                Type = new Type.Proc(
                    true,
                    new List <Type.Proc.Param> {
                    new Type.Proc.Param(typeParamSymbol, Type.Type_),
                },
                    Type.Type_);
            }
Ejemplo n.º 4
0
        public ExternIntrinsic(IDependencySystem system)
            : base(system)
        {
            // TODO: Ease building these?
            var nameParamSymbol = new Symbol.Var(null, "name", Symbol.VarKind.Param);
            var typeParamSymbol = new Symbol.Var(null, "T", Symbol.VarKind.Param);
            var stringType      = System.ReferToConstType("@c", "str");
            var typeType        = Type.Type_;

            Type = new Type.Proc(
                true,
                new List <Type.Proc.Param> {
                new Type.Proc.Param(nameParamSymbol, stringType),
                new Type.Proc.Param(typeParamSymbol, typeType),
            },
                new Type.Dependent(typeParamSymbol));
        }
Ejemplo n.º 5
0
        protected override object?Visit(Statement.Return ret)
        {
            Debug.Assert(currentProcReturnType != null);

            base.Visit(ret);
            Type retType = ret.Value == null ? Type.Unit : System.TypeOf(ret.Value);

            if (!currentProcReturnType.Equals(retType))
            {
                // Error, work out what we know
                Debug.Assert(currentProcSignature != null);
                var signature  = (Syntax.ParseTree.Expression.ProcSignature?)currentProcSignature.ParseTreeNode;
                var definition = (Syntax.ParseTree.IParseTreeElement?)signature?.Return ?? signature?.CloseParen;
                var wrong      = ((Node?)FindDeepestReturnValue(ret.Value) ?? ret)?.ParseTreeNode;
                System.Report(new TypeMismatchError(currentProcReturnType, retType)
                {
                    Defined           = definition,
                    Wrong             = wrong,
                    Context           = "return value",
                    ImplicitlyDefined = signature != null && signature.Return == null,
                });
            }
            return(null);
        }
Ejemplo n.º 6
0
 // TODO: Doc
 public void DefineBuiltinType(string name, Type type) =>
 DefineBuiltin(name, Type.Type_, new Value.User(type));
Ejemplo n.º 7
0
 // TODO: Doc
 public void DefineBuiltin(string name, Type type, Value value) =>
 GlobalScope.Define(new Symbol.Const(name, type, value));
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new <see cref="Const"/> by a name and <see cref="Value"/>.
 /// </summary>
 /// <param name="name">The name of the symbol.</param>
 /// <param name="type">The <see cref="Type"/> of the symbol.</param>
 /// <param name="value">The <see cref="Value"/> of the symbol.</param>
 public Const(string name, Type type, Value value)
     : this(null, name, type, value)
 {
 }