public CompilerContext(CompilerSettings settings, Report report) { this.settings = settings; this.report = report; this.builtin_types = new BuiltinTypes(); this.TimeReporter = DisabledTimeReporter; }
public CompilerContext(CompilerSettings settings, ReportPrinter reportPrinter) { this.settings = settings; this.report = new Report(this, reportPrinter); this.builtin_types = new BuiltinTypes(); this.TimeReporter = DisabledTimeReporter; }
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)); } }
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)); } }
public BoolLiteral(BuiltinTypes types, bool val, Location loc) : base(types, val, loc) { }
public StringLiteral(BuiltinTypes types, string s, Location loc) : base(types, s, loc) { }
public DecimalLiteral(BuiltinTypes types, decimal d, Location loc) : base(types, d, loc) { }
public DoubleLiteral(BuiltinTypes types, double d, Location loc) : base(types, d, loc) { }
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 ?? ""; }
public CharLiteral(BuiltinTypes types, char c, Location loc) : base(types, c, loc) { }
public TimeLiteral(BuiltinTypes types, System.TimeSpan s, Location loc) : base(types, s, loc) { }
public DateLiteral(BuiltinTypes types, System.DateTime s, Location loc) : base(types, s, loc) { }
public QuadLiteral(BuiltinTypes types, Quad s, Location loc) : base(types, s, loc) { }
public ReflectionImporter(ModuleContainer module, BuiltinTypes builtin) { throw new NotSupportedException(); }
public UIntLiteral(BuiltinTypes types, uint l, Location loc) : base(types, l, loc) { }
public ULongLiteral(BuiltinTypes types, ulong l, Location loc) : base(types, l, loc) { }
public StaticImporter(BuiltinTypes builtin) { throw new NotSupportedException(); }
public FloatLiteral(BuiltinTypes types, float f, Location loc) : base(types, f, loc) { }
public XmlLiteral(BuiltinTypes types, string xml, Location loc) : base(loc) { Xml = xml; }
public ComplexLiteral(BuiltinTypes types, Complex d, Location loc) : base(types, d, loc) { }