/// <nodoc /> public ModuleRegistry(SymbolTable symbolTable) { PrimitiveTypes = new PrimitiveTypes(symbolTable.StringTable); GlobalLiteral = new GlobalModuleLiteral(symbolTable); PredefinedTypes = new Ambients.PredefinedTypes(PrimitiveTypes); PredefinedTypes.Register(GlobalLiteral); }
public void InitializePredefinedTypes() { predefined_attributes = new PredefinedAttributes(this); predefined_types = new PredefinedTypes(this); predefined_members = new PredefinedMembers(this); OperatorsBinaryEqualityLifted = Binary.CreateEqualityLiftedOperatorsTable(this); OperatorsBinaryLifted = Binary.CreateStandardLiftedOperatorsTable(this); }
/// <summary> /// Tries to project this expression based on the given name. /// </summary> /// <remarks> /// This method returns true if the kind of expression is eligible for projection. /// The returned value can be undefined though. /// </remarks> public virtual bool TryProject( Context context, SymbolAtom name, ModuleLiteral origin, PredefinedTypes predefinedTypes, out EvaluationResult result, LineInfo location) { Contract.Requires(context != null); Contract.Requires(name.IsValid); Contract.Requires(origin != null); Contract.Requires(predefinedTypes != null); result = EvaluationResult.Error; return(false); }
public void LoadPredefinedTypes_Test() { // Arrange var root = new NamespaceSymbol { FullName = "<root>", Kind = "root" }; var globalTypes = new NLiquidGlobalTypes(root.MemberTable); var filters = FilterTypes.Create(root.MemberTable, globalTypes); // Act var predefinedTypes = new PredefinedTypes(globalTypes, filters); // Assert Assert.NotNull(predefinedTypes.GlobalTypes); Assert.NotNull(predefinedTypes.Filters); CollectionAssert.IsNotEmpty(predefinedTypes.Symbols); }
/// <summary> /// Provides the type associated to the name /// </summary> /// <param name="nameSpace"></param> /// <param name="name"></param> /// <returns></returns> public Types.Type findType(Types.NameSpace nameSpace, string name) { Types.Type retVal = null; if (name != null) { foreach (Dictionary dictionary in Dictionaries) { retVal = dictionary.findType(nameSpace, name); if (retVal != null) { break; } } if (retVal == null) { PredefinedTypes.TryGetValue(name, out retVal); } } return(retVal); }
/// <inheritdoc /> public sealed override bool TryProject(Context context, SymbolAtom name, ModuleLiteral origin, PredefinedTypes predefinedTypes, out EvaluationResult result, LineInfo location) { result = GetOrEvalField(context, name, recurs: false, origin: origin, location: Location); return(true); }
public static void ChangeWindowStyle(IntPtr handle, PredefinedTypes.CustomWindowStyles wndStyle) { if (wndStyle.Equals(PredefinedTypes.CustomWindowStyles.Clickable)) { var initial = GetWindowLong(handle, (Int32)Gwl.ExStyle); SetWindowLong(handle, (Int32)Gwl.ExStyle, (IntPtr)(initial & ~(Int32)Ws.ExTransparent)); } else if (wndStyle.Equals(PredefinedTypes.CustomWindowStyles.NotClickable)) { var initial = GetWindowLong(handle, (Int32)Gwl.ExStyle); SetWindowLong(handle, (Int32)Gwl.ExStyle, (IntPtr)(initial | (Int32)Ws.ExTransparent)); } }
public void SetSelection(PredefinedTypes.LSelection selection) { /* Derp */ }
public void InitializePredefinedTypes () { predefined_attributes = new PredefinedAttributes (this); predefined_types = new PredefinedTypes (this); predefined_members = new PredefinedMembers (this); }
private void ErrAppendType(CType pType, SubstContext pctx, bool fArgs) { if (pctx != null) { if (!pctx.FNop()) { pType = GetTypeManager().SubstType(pType, pctx); } // We shouldn't use the SubstContext again so set it to NULL. pctx = null; } switch (pType.GetTypeKind()) { case TypeKind.TK_AggregateType: { AggregateType pAggType = pType.AsAggregateType(); // Check for a predefined class with a special "nice" name for // error reported. string text = PredefinedTypes.GetNiceName(pAggType.getAggregate()); if (text != null) { // Found a nice name. ErrAppendString(text); } else if (pAggType.getAggregate().IsAnonymousType()) { ErrAppendPrintf("AnonymousType#{0}", GetTypeID(pAggType)); break; } else { if (pAggType.outerType != null) { ErrAppendType(pAggType.outerType, pctx); ErrAppendChar('.'); } else { // In a namespace. ErrAppendParentSym(pAggType.getAggregate(), pctx); } ErrAppendName(pAggType.getAggregate().name); } ErrAppendTypeParameters(pAggType.GetTypeArgsThis(), pctx, true); break; } case TypeKind.TK_TypeParameterType: if (null == pType.GetName()) { // It's a standard type variable. if (pType.AsTypeParameterType().IsMethodTypeParameter()) { ErrAppendChar('!'); } ErrAppendChar('!'); ErrAppendPrintf("{0}", pType.AsTypeParameterType().GetIndexInTotalParameters()); } else { ErrAppendName(pType.GetName()); } break; case TypeKind.TK_ErrorType: if (pType.AsErrorType().HasParent()) { Debug.Assert(pType.AsErrorType().nameText != null && pType.AsErrorType().typeArgs != null); ErrAppendParentType(pType, pctx); ErrAppendName(pType.AsErrorType().nameText); ErrAppendTypeParameters(pType.AsErrorType().typeArgs, pctx, true); } else { // Load the string "<error>". Debug.Assert(null == pType.AsErrorType().typeArgs); ErrAppendId(MessageID.ERRORSYM); } break; case TypeKind.TK_NullType: // Load the string "<null>". ErrAppendId(MessageID.NULL); break; case TypeKind.TK_OpenTypePlaceholderType: // Leave blank. break; case TypeKind.TK_BoundLambdaType: ErrAppendId(MessageID.AnonMethod); break; case TypeKind.TK_UnboundLambdaType: ErrAppendId(MessageID.Lambda); break; case TypeKind.TK_MethodGroupType: ErrAppendId(MessageID.MethodGroup); break; case TypeKind.TK_ArgumentListType: ErrAppendString(TokenFacts.GetText(TokenKind.ArgList)); break; case TypeKind.TK_ArrayType: { CType elementType = pType.AsArrayType().GetBaseElementType(); if (null == elementType) { Debug.Assert(false, "No element type"); break; } ErrAppendType(elementType, pctx); for (elementType = pType; elementType != null && elementType.IsArrayType(); elementType = elementType.AsArrayType().GetElementType()) { int rank = elementType.AsArrayType().rank; // Add [] with (rank-1) commas inside ErrAppendChar('['); // known rank. if (rank == 1) { if (!elementType.AsArrayType().IsSZArray) { ErrAppendChar('*'); } } else { for (int i = rank; i > 1; --i) { ErrAppendChar(','); } } ErrAppendChar(']'); } break; } case TypeKind.TK_VoidType: ErrAppendName(GetNameManager().Lookup(TokenFacts.GetText(TokenKind.Void))); break; case TypeKind.TK_ParameterModifierType: // add ref or out ErrAppendString(pType.AsParameterModifierType().isOut ? "out " : "ref "); // add base type name ErrAppendType(pType.AsParameterModifierType().GetParameterType(), pctx); break; case TypeKind.TK_PointerType: // Generate the base type. ErrAppendType(pType.AsPointerType().GetReferentType(), pctx); { // add the trailing * ErrAppendChar('*'); } break; case TypeKind.TK_NullableType: ErrAppendType(pType.AsNullableType().GetUnderlyingType(), pctx); ErrAppendChar('?'); break; case TypeKind.TK_NaturalIntegerType: default: // Shouldn't happen. Debug.Assert(false, "Bad type kind"); break; } }
public void SetGameinfo(PredefinedTypes.Gameinformation gameinfo) { if (gameinfo != null) _rndMainWindow.GInfo = gameinfo; }
/// <inheritdoc /> public override bool TryProject(Context context, SymbolAtom name, ModuleLiteral origin, PredefinedTypes predefinedTypes, out EvaluationResult result, LineInfo location) { if (name == context.ContextTree.CommonConstants.Length) { result = EvaluationResult.Create(Length); return true; } var resolvedMember = predefinedTypes.AmbientArray.ResolveMember(this, name); if (resolvedMember == null) { // Array literals could not have arbitrary members. // So if the name was not resolved, reporting an error. // var locationForLogging = LocationForLogging(context, origin); var locationForLogging = UniversalLocation.FromLineInfo(location, origin.Path, context.PathTable); context.Logger.ReportMissingInstanceMember( context.LoggingContext, locationForLogging.AsLoggingLocation(), name.ToDisplayString(context), DisplayStringHelper.TypeToString(GetType(), context), context.GetStackTraceAsString(locationForLogging)); result = EvaluationResult.Error; } else { result = EvaluationResult.Create(resolvedMember); } return true; }
/// <inheritdoc /> public override bool TryProject(Context context, SymbolAtom name, ModuleLiteral origin, PredefinedTypes predefinedTypes, out EvaluationResult result, LineInfo location) { var value = this[name.StringId]; if (value.IsUndefined) { // TODO: Optimize this for look-up miss cases (there can be tons of them). var resolvedMember = predefinedTypes.AmbientObject.ResolveMember(this, name) ?? (object)UndefinedValue.Instance; result = EvaluationResult.Create(resolvedMember); } else { result = value; } return(true); }
public void InitializePredefinedTypes () { predefined_attributes = new PredefinedAttributes (this); predefined_types = new PredefinedTypes (this); predefined_members = new PredefinedMembers (this); OperatorsBinaryEqualityLifted = Binary.CreateEqualityLiftedOperatorsTable (this); OperatorsBinaryLifted = Binary.CreateStandardLiftedOperatorsTable (this); }
public void InitializePredefinedTypes() { predefined_attributes = new PredefinedAttributes(this); predefined_types = new PredefinedTypes(this); predefined_members = new PredefinedMembers(this); }
public static void Click(IntPtr handle, PredefinedTypes.MouseButtons btn, params Point[] position) { foreach (var t in position) { switch (btn) { case PredefinedTypes.MouseButtons.MouseLeft: Interop.SendMessage(handle, (uint) Interop.WMessages.Lbuttondown, IntPtr.Zero, (IntPtr) MakeLParam(t)); Interop.SendMessage(handle, (uint)Interop.WMessages.Lbuttonup, IntPtr.Zero, (IntPtr)MakeLParam(t)); break; case PredefinedTypes.MouseButtons.MouseRight: Interop.SendMessage(handle, (uint) Interop.WMessages.Rbuttondown, IntPtr.Zero, (IntPtr) MakeLParam(t)); Interop.SendMessage(handle, (uint)Interop.WMessages.Rbuttonup, IntPtr.Zero, (IntPtr)MakeLParam(t)); break; case PredefinedTypes.MouseButtons.MouseMiddle: Interop.SendMessage(handle, (uint)Interop.WMessages.Mbuttondown, IntPtr.Zero, (IntPtr)MakeLParam(t)); Interop.SendMessage(handle, (uint)Interop.WMessages.Mbuttonup, IntPtr.Zero, (IntPtr)MakeLParam(t)); break; case PredefinedTypes.MouseButtons.MouseLeftDown: Interop.SendMessage(handle, (uint)Interop.WMessages.Lbuttondown, IntPtr.Zero, (IntPtr)MakeLParam(t)); break; case PredefinedTypes.MouseButtons.MouseLeftUp: Interop.SendMessage(handle, (uint)Interop.WMessages.Lbuttonup, IntPtr.Zero, (IntPtr)MakeLParam(t)); break; case PredefinedTypes.MouseButtons.MouseRightDown: Interop.SendMessage(handle, (uint)Interop.WMessages.Rbuttondown, IntPtr.Zero, (IntPtr)MakeLParam(t)); break; case PredefinedTypes.MouseButtons.MouseRightUp: Interop.SendMessage(handle, (uint)Interop.WMessages.Rbuttonup, IntPtr.Zero, (IntPtr)MakeLParam(t)); break; case PredefinedTypes.MouseButtons.MouseMiddleDown: Interop.SendMessage(handle, (uint)Interop.WMessages.Mbuttondown, IntPtr.Zero, (IntPtr)MakeLParam(t)); break; case PredefinedTypes.MouseButtons.MouseMiddleUp: Interop.SendMessage(handle, (uint)Interop.WMessages.Mbuttonup, IntPtr.Zero, (IntPtr)MakeLParam(t)); break; } } }
private void ErrAppendSym(Symbol sym, SubstContext pctx, bool fArgs) { switch (sym.getKind()) { case SYMKIND.SK_AggregateDeclaration: ErrAppendSym(sym.AsAggregateDeclaration().Agg(), pctx); break; case SYMKIND.SK_AggregateSymbol: { // Check for a predefined class with a special "nice" name for // error reported. string text = PredefinedTypes.GetNiceName(sym.AsAggregateSymbol()); if (text != null) { // Found a nice name. ErrAppendString(text); } else if (sym.AsAggregateSymbol().IsAnonymousType()) { ErrAppendId(MessageID.AnonymousType); break; } else { ErrAppendParentSym(sym, pctx); ErrAppendName(sym.name); ErrAppendTypeParameters(sym.AsAggregateSymbol().GetTypeVars(), pctx, true); } break; } case SYMKIND.SK_MethodSymbol: ErrAppendMethod(sym.AsMethodSymbol(), pctx, fArgs); break; case SYMKIND.SK_PropertySymbol: ErrAppendProperty(sym.AsPropertySymbol(), pctx); break; case SYMKIND.SK_EventSymbol: ErrAppendEvent(sym.AsEventSymbol(), pctx); break; case SYMKIND.SK_AssemblyQualifiedNamespaceSymbol: case SYMKIND.SK_NamespaceSymbol: if (sym == getBSymmgr().GetRootNS()) { ErrAppendId(MessageID.GlobalNamespace); } else { ErrAppendParentSym(sym, null); ErrAppendName(sym.name); } break; case SYMKIND.SK_FieldSymbol: ErrAppendParentSym(sym, pctx); ErrAppendName(sym.name); break; case SYMKIND.SK_TypeParameterSymbol: if (null == sym.name) { // It's a standard type variable. if (sym.AsTypeParameterSymbol().IsMethodTypeParameter()) { ErrAppendChar('!'); } ErrAppendChar('!'); ErrAppendPrintf("{0}", sym.AsTypeParameterSymbol().GetIndexInTotalParameters()); } else { ErrAppendName(sym.name); } break; case SYMKIND.SK_LocalVariableSymbol: // Generate symbol name. ErrAppendName(sym.name); break; case SYMKIND.SK_Scope: case SYMKIND.SK_LambdaScope: default: // Shouldn't happen. Debug.Assert(false, $"Bad symbol kind: {sym.getKind()}"); break; } }
public void SetMap(PredefinedTypes.Map map) { /* Derp */ }
internal static bool IsPredefinedType(this Type type) { return(PredefinedTypes.Any(t => t == type)); }
public void SetPlayers(PredefinedTypes.PList players) { if (players != null) _rndMainWindow.PList = players; }