Exemple #1
0
 public CompilerContext(CompilerSettings settings, Report report)
 {
     this.settings      = settings;
     this.report        = report;
     this.builtin_types = new BuiltinTypes();
     this.TimeReporter  = DisabledTimeReporter;
 }
Exemple #2
0
 public CompilerContext(CompilerSettings settings, ReportPrinter reportPrinter)
 {
     this.settings      = settings;
     this.report        = new Report(this, reportPrinter);
     this.builtin_types = new BuiltinTypes();
     this.TimeReporter  = DisabledTimeReporter;
 }
Exemple #3
0
        public static FullNamedExpression CreateDelegateTypeExpression(BuiltinTypes builtinTypes, ParametersCompiled parameters, FullNamedExpression retType, Location loc)
        {
            // Setup
            bool   hasParams   = parameters != null && parameters.Count > 0;
            int    paramCount  = hasParams ? parameters.Count : 0;
            string ns          = "System";
            string paramSuffix = "";

            // If last parameter is a PARAMS paramter, use the params versions of the delegate types
            if (hasParams && (parameters.FixedParameters [parameters.FixedParameters.Length - 1].ModFlags & Parameter.Modifier.PARAMS) != 0)
            {
                ns          = "PlayScript";
                paramSuffix = "P";
                paramCount--;
            }

            // Check if this is Func or Action
            bool hasRetType     = !(retType is TypeExpression && ((TypeExpression)retType).Type == builtinTypes.Void);
            int  typeParamCount = paramCount;

            if (hasRetType)
            {
                typeParamCount++;
            }

            // Create arguments list
            TypeArguments typeArgs = null;

            if (typeParamCount > 0)
            {
                var typeArgArray = new FullNamedExpression[typeParamCount];
                for (var i = 0; i < typeParamCount; i++)
                {
                    if (i < paramCount)
                    {
                        var param = parameters.FixedParameters[i] as Parameter;
                        typeArgArray[i] = param.TypeExpression;
                    }
                    else
                    {
                        typeArgArray[i] = retType;
                    }
                }
                typeArgs = new TypeArguments(typeArgArray);
            }

            // Return the expression for the type we want
            if (!hasRetType)
            {
                return(new MemberAccess(new SimpleName(ns, loc), "Action" + paramSuffix, typeArgs, loc));
            }
            else
            {
                return(new MemberAccess(new SimpleName(ns, loc), "Func" + paramSuffix, typeArgs, loc));
            }
        }
Exemple #4
0
        public static FullNamedExpression CreateDelegateTypeExpression(BuiltinTypes builtinTypes, ParametersCompiled parameters, FullNamedExpression retType, Location loc)
        {
            bool hasParams      = parameters != null && parameters.Count > 0;
            int  paramCount     = hasParams ? parameters.Count : 0;
            bool hasRetType     = !(retType is TypeExpression && ((TypeExpression)retType).Type == builtinTypes.Void);
            int  typeParamCount = paramCount;

            if (hasRetType)
            {
                typeParamCount++;
            }
            TypeArguments typeArgs = null;

            if (typeParamCount > 0)
            {
                var typeArgArray = new FullNamedExpression[typeParamCount];
                for (var i = 0; i < typeParamCount; i++)
                {
                    if (i < paramCount)
                    {
                        var param = parameters.FixedParameters[i] as Parameter;
                        typeArgArray[i] = param.TypeExpression;
                    }
                    else
                    {
                        typeArgArray[i] = retType;
                    }
                }
                typeArgs = new TypeArguments(typeArgArray);
            }
            if (!hasRetType)
            {
                return(new MemberAccess(new SimpleName("System", loc), "Action", typeArgs, loc));
            }
            else
            {
                return(new MemberAccess(new SimpleName("System", loc), "Func", typeArgs, loc));
            }
        }
Exemple #5
0
 public BoolLiteral(BuiltinTypes types, bool val, Location loc)
     : base(types, val, loc)
 {
 }
Exemple #6
0
 public StringLiteral(BuiltinTypes types, string s, Location loc)
     : base(types, s, loc)
 {
 }
Exemple #7
0
 public DecimalLiteral(BuiltinTypes types, decimal d, Location loc)
     : base(types, d, loc)
 {
 }
Exemple #8
0
 public DoubleLiteral(BuiltinTypes types, double d, Location loc)
     : base(types, d, loc)
 {
 }
Exemple #9
0
 public VLongLiteral(BuiltinTypes types, VLong s, Location loc)
     : base(types, s, loc)
 {
 }
 public RegexLiteral(BuiltinTypes types, string regex, string options, Location loc)
     : base(loc)
 {
     Regex   = regex;
     Options = options ?? "";
 }
Exemple #11
0
 public CharLiteral(BuiltinTypes types, char c, Location loc)
     : base(types, c, loc)
 {
 }
Exemple #12
0
 public TimeLiteral(BuiltinTypes types, System.TimeSpan s, Location loc)
     : base(types, s, loc)
 {
 }
Exemple #13
0
 public DateLiteral(BuiltinTypes types, System.DateTime s, Location loc)
     : base(types, s, loc)
 {
 }
Exemple #14
0
 public QuadLiteral(BuiltinTypes types, Quad s, Location loc)
     : base(types, s, loc)
 {
 }
Exemple #15
0
 public ReflectionImporter(ModuleContainer module, BuiltinTypes builtin)
 {
     throw new NotSupportedException();
 }
Exemple #16
0
 public UIntLiteral(BuiltinTypes types, uint l, Location loc)
     : base(types, l, loc)
 {
 }
Exemple #17
0
 public ULongLiteral(BuiltinTypes types, ulong l, Location loc)
     : base(types, l, loc)
 {
 }
Exemple #18
0
 public StaticImporter(BuiltinTypes builtin)
 {
     throw new NotSupportedException();
 }
Exemple #19
0
 public FloatLiteral(BuiltinTypes types, float f, Location loc)
     : base(types, f, loc)
 {
 }
 public XmlLiteral(BuiltinTypes types, string xml, Location loc)
     : base(loc)
 {
     Xml = xml;
 }
Exemple #21
0
 public ComplexLiteral(BuiltinTypes types, Complex d, Location loc)
     : base(types, d, loc)
 {
 }