public TernaryExpression(IParseExpression condition, IParseExpression consequent, IParseExpression alternative) { Condition = condition; Consequent = consequent; Alternative = alternative; Range = condition.Range.Start + alternative.Range.End; }
public MacroVar(ParseInfo parseInfo, Scope objectScope, Scope staticScope, MacroVarDeclaration macroContext, CodeType returnType) { _context = macroContext; Name = macroContext.Identifier.Text; // Get the attributes. FunctionAttributesGetter attributeResult = new MacroAttributesGetter(macroContext, new MacroVarAttribute(this)); attributeResult.GetAttributes(parseInfo.Script.Diagnostics); DocRange nameRange = macroContext.Identifier.Range; ContainingType = (Static ? staticScope : objectScope).This; DefinedAt = new Location(parseInfo.Script.Uri, nameRange); _recursiveCallHandler = new RecursiveCallHandler(this); CallInfo = new CallInfo(_recursiveCallHandler, parseInfo.Script); CodeType = returnType; _expressionToParse = macroContext.Value; _scope = Static ? staticScope : objectScope; this._parseInfo = parseInfo; _scope.AddMacro(this, parseInfo.Script.Diagnostics, nameRange, !Override); parseInfo.TranslateInfo.GetComponent <SymbolLinkComponent>().AddSymbolLink(this, DefinedAt, true); parseInfo.Script.AddHover(nameRange, GetLabel(true)); parseInfo.Script.AddCodeLensRange(new ReferenceCodeLensRange(this, parseInfo, CodeLensSourceType.Variable, DefinedAt.range)); if (Override) { MacroVar overriding = (MacroVar)objectScope.GetMacroOverload(Name, DefinedAt); if (overriding == this) { parseInfo.Script.Diagnostics.Error("Overriding itself!", nameRange); } // No method with the name and parameters found. if (overriding == null) { parseInfo.Script.Diagnostics.Error("Could not find a macro to override.", nameRange); } else if (!overriding.IsOverridable) { parseInfo.Script.Diagnostics.Error("The specified macro is not marked as virtual.", nameRange); } else { overriding.Overriders.Add(this); } if (overriding != null && overriding.DefinedAt != null) { // Make the override keyword go to the base method. parseInfo.Script.AddDefinitionLink( attributeResult.ObtainedAttributes.First(at => at.Type == MethodAttributeType.Override).Range, overriding.DefinedAt ); } } }
public Var(VarInfo varInfo) { Name = varInfo.Name; DefinedAt = varInfo.DefinedAt; _parseInfo = varInfo.ParseInfo; AccessLevel = varInfo.AccessLevel; WholeContext = varInfo.WholeContext; CodeType = varInfo.Type; InExtendedCollection = varInfo.InExtendedCollection; Ref = varInfo.Ref; ID = varInfo.ID; Static = varInfo.Static; Recursive = varInfo.Recursive; BridgeInvocable = varInfo.BridgeInvocable; RequiresCapture = varInfo.RequiresCapture; IsMacro = varInfo.IsMacro; Virtual = varInfo.Virtual; Override = varInfo.Override; _tokenType = varInfo.TokenType; _tokenModifiers = varInfo.TokenModifiers.ToArray(); _handleRestrictedCalls = varInfo.HandleRestrictedCalls; _inferType = varInfo.InferType; _initialValueContext = varInfo.InitialValueContext; _initialValueResolve = varInfo.InitialValueResolve; _operationalScope = varInfo.Scope; _variableTypeHandler = varInfo.VariableTypeHandler; if (!_inferType) { AddScriptData(); } if (ID != -1) { if (VariableType == VariableType.Global) { _parseInfo.TranslateInfo.VarCollection.Reserve(ID, true, _parseInfo.Script.Diagnostics, DefinedAt.range); } else if (VariableType == VariableType.Player) { _parseInfo.TranslateInfo.VarCollection.Reserve(ID, false, _parseInfo.Script.Diagnostics, DefinedAt.range); } } // Get the initial value. if (_initialValueResolve == InitialValueResolve.Instant) { GetInitialValue(); } else { _parseInfo.TranslateInfo.StagedInitiation.On(InitiationStage.Content, GetInitialValue); } if (DefinedAt != null) { _parseInfo.Script.AddCodeLensRange(new ReferenceCodeLensRange(this, _parseInfo, varInfo.CodeLensType, DefinedAt.range)); _parseInfo.Script.Elements.AddDeclarationCall(this, new DeclarationCall(DefinedAt.range, true)); } }
public Foreach(IParseType type, Token identifier, IParseExpression expression, IParseStatement statement) { Type = type; Identifier = identifier; Expression = expression; Statement = statement; }
public Assignment(IParseExpression variableExpression, Token assignmentToken, IParseExpression value, Token actionComment) { VariableExpression = variableExpression; AssignmentToken = assignmentToken; Value = value; ActionComment = actionComment; }
public MacroVarDeclaration(AttributeTokens attributes, IParseType type, Token identifier, IParseExpression value) { Attributes = attributes; Type = type; Identifier = identifier; Value = value; }
public If(IParseExpression expression, IParseStatement statement, List <ElseIf> elseIfs, Else els) { Expression = expression; Statement = statement; ElseIfs = elseIfs; Else = els; }
public BinaryOperatorExpression(IParseExpression left, IParseExpression right, OperatorInfo op) { Left = left; Right = right; Operator = op; Range = left.Range.Start + right.Range.End; }
/// <summary>Gets an IExpression from an ExprContext.</summary> /// <param name="scope">The scope the expression was called in.</param> /// <param name="exprContext">The context of the expression/</param> /// <param name="selfContained">Determines if the expression is not an expression tree.</param> /// <param name="usedAsValue">Determines if the expression is being used as a value.</param> /// <param name="getter">The getter scope. Used for preserving scope through parameters.</param> /// <returns>An IExpression created from the ExprContext.</returns> public IExpression GetExpression(Scope scope, IParseExpression exprContext, bool selfContained = true, bool usedAsValue = true, Scope getter = null) { if (getter == null) { getter = scope; } switch (exprContext) { case NumberExpression number: return(new NumberAction(Script, number)); case BooleanExpression boolean: return(new BoolAction(Script, boolean.Value)); case NullExpression @null: return(new NullAction()); case StringExpression @string: return(new StringAction(this, scope, @string)); case Identifier identifier: return(GetVariable(scope, getter, identifier, selfContained)); case FunctionExpression method: return(new CallMethodAction(this, scope, method, usedAsValue, getter)); case NewExpression newObject: return(new CreateObjectAction(this, scope, newObject)); case BinaryOperatorExpression op: if (op.IsDotExpression()) { return(new ExpressionTree(this, scope, op, usedAsValue)); } else { return(new OperatorAction(this, scope, op)); } case UnaryOperatorExpression op: return(new UnaryOperatorAction(this, scope, op)); case TernaryExpression op: return(new TernaryConditionalAction(this, scope, op)); case ValueInArray arrayIndex: return(new ValueInArrayAction(this, scope, arrayIndex)); case CreateArray createArray: return(new CreateArrayAction(this, scope, createArray)); case ExpressionGroup group: return(GetExpression(scope, group.Expression)); case TypeCast typeCast: return(new TypeConvertAction(this, scope, typeCast)); case ThisExpression @this: return(new ThisAction(this, scope, @this)); case RootExpression root: return(new RootAction(this.TranslateInfo)); case LambdaExpression lambda: return(new Lambda.LambdaAction(this, scope, lambda)); case AsyncContext asyncContext: return(AsyncInfo.ParseAsync(this, scope, asyncContext, usedAsValue)); // Missing case MissingElement missing: return(MissingElementAction.MissingElement); default: throw new Exception($"Could not determine the expression type '{exprContext.GetType().Name}'."); } }
public MacroFunctionContext(AttributeTokens attributes, IParseType type, Token identifier, List <VariableDeclaration> parameters, IParseExpression expression) { Attributes = attributes; Type = type; Identifier = identifier; Parameters = parameters; Expression = expression; }
public For(IParseStatement initializer, IParseExpression condition, IParseStatement iterator, IParseStatement block, Token initializerSemicolon) { Initializer = initializer; Condition = condition; Iterator = iterator; Block = block; InitializerSemicolon = initializerSemicolon; }
public VariableDeclaration(AttributeTokens attributes, IParseType type, Token identifier, IParseExpression initialValue, Token ext, Token id) { Attributes = attributes; Type = type; Identifier = identifier; InitialValue = initialValue; Extended = ext; ID = id; }
public Var(VarInfo varInfo) { Name = varInfo.Name; DefinedAt = varInfo.DefinedAt; parseInfo = varInfo.ParseInfo; AccessLevel = varInfo.AccessLevel; DefinedAt = varInfo.DefinedAt; WholeContext = varInfo.WholeContext; CodeType = varInfo.Type; VariableType = varInfo.VariableType; StoreType = varInfo.StoreType; InExtendedCollection = varInfo.InExtendedCollection; ID = varInfo.ID; Static = varInfo.Static; Recursive = varInfo.Recursive; BridgeInvocable = varInfo.BridgeInvocable; RequiresCapture = varInfo.RequiresCapture; _tokenType = varInfo.TokenType; _tokenModifiers = varInfo.TokenModifiers.ToArray(); _handleRestrictedCalls = varInfo.HandleRestrictedCalls; _initalValueContext = varInfo.InitialValueContext; _initialValueResolve = varInfo.InitialValueResolve; _operationalScope = varInfo.OperationalScope; if (ID != -1) { if (VariableType == VariableType.Global) { parseInfo.TranslateInfo.VarCollection.Reserve(ID, true, parseInfo.Script.Diagnostics, DefinedAt.range); } else if (VariableType == VariableType.Player) { parseInfo.TranslateInfo.VarCollection.Reserve(ID, false, parseInfo.Script.Diagnostics, DefinedAt.range); } } if (DefinedAt.range != null) { parseInfo.Script.AddToken(DefinedAt.range, _tokenType, _tokenModifiers); parseInfo.Script.AddHover(DefinedAt.range, GetLabel(true)); parseInfo.TranslateInfo.GetComponent <SymbolLinkComponent>().AddSymbolLink(this, DefinedAt, true); } if (_initialValueResolve == InitialValueResolve.Instant) { GetInitialValue(); } else { parseInfo.TranslateInfo.ApplyBlock(this); } parseInfo.Script.AddCodeLensRange(new ReferenceCodeLensRange(this, parseInfo, varInfo.CodeLensType, DefinedAt.range)); }
public SwitchCase(Token caseToken, IParseExpression value) { Token = caseToken; Value = value; IsDefault = false; }
public Switch(IParseExpression expression, List <IParseStatement> statements) { Expression = expression; Statements = statements; }
public ElseIf(IParseExpression expression, IParseStatement statement) { Expression = expression; Statement = statement; }
public Return(Token token, IParseExpression expression) { Token = token; Expression = expression; }
public Increment(IParseExpression variableExpression, bool decrement) { VariableExpression = variableExpression; Decrement = decrement; }
public FunctionExpression(IParseExpression target, List <ParameterValue> parameters) { Target = target; Parameters = parameters; }
public AsyncContext(Token asyncToken, Token ignoreIfRunning, IParseExpression expression) { AsyncToken = asyncToken; IgnoreIfRunning = ignoreIfRunning; Expression = expression; }
public TypeCast(IParseType type, IParseExpression expression) { Type = type; Expression = expression; }
public ExpressionGroup(IParseExpression expression, Token left, Token right) { Expression = expression; Left = left; Right = right; }
public Delete(IParseExpression deleting) { Deleting = deleting; }
public EnumValue(Token identifier, IParseExpression value) { Identifier = identifier; Value = value; }
public ParameterValue(Token pickyParameter, IParseExpression value) { PickyParameter = pickyParameter; Expression = value; }
public ExpressionStatement(IParseExpression expression, Token actionComment) { Expression = expression; ActionComment = actionComment; Range = expression.Range; }
public ArrayIndex(IParseExpression expression, Token leftBracket, Token rightBracket) { Expression = expression; LeftBracket = leftBracket; RightBracket = rightBracket; }
public Hook(IParseExpression variable, IParseExpression value) { Variable = variable; Value = value; }
public InitialValueAttribute(IParseExpression exprContext) : base(AttributeType.Initial, exprContext.Range) { ExprContext = exprContext; }
public ValueInArray(IParseExpression array, IParseExpression index, Token closingToken) { Array = array; Index = index; Range = new DocRange(Array.Range.Start, closingToken.Range.End); }