public SceneSymbol?ResolveCallSceneTarget(CallSceneStatement callSceneStmt) { if (callSceneStmt.TargetModule is null) { return(LookupScene(callSceneStmt.TargetScene)); } Spanned <string> targetModule = callSceneStmt.TargetModule.Value; string modulePath = targetModule.Value; try { SourceModuleSymbol targetSourceModule = _compilation.GetSourceModule(modulePath); SceneSymbol? scene = targetSourceModule.LookupScene(callSceneStmt.TargetScene.Value); if (scene is null) { ReportUnresolvedIdentifier(callSceneStmt.TargetScene); } return(scene); } catch (FileNotFoundException) { string moduleName = targetModule.Value; Report(targetModule, DiagnosticId.ExternalModuleNotFound, moduleName); return(null); } }
private void ResolveTy(Spanned<TyRef> spTy) { var ty = spTy.value as PathTyRef; if (ty != null && !ty.Resolved) { if (!ty.Resolved) { // TODO(kai): eventually this will all be qualified, we'll have to deal with that. var name = ty.name; var sym = walker.Current.Lookup(name); if (sym == null) { // TODO(kai): use spanned types log.Error(spTy.span, "Could not locate symbol \"{0}\", failed to resolve type.", name); return; } var symTy = sym.Ty; if (symTy is PathTyRef) { if ((symTy as PathTyRef).Resolved) ty.Resolve(symTy); else hasResolved = false; } else ty.Resolve(symTy); } } }
// TODO(kai): default values public Parameter(Spanned<string> name, Spanned<TyRef> spTy) { if (spTy == null) throw new System.ArgumentNullException("spTy"); this.spTy = spTy; this.name = name; }
internal UnaryExpression( Expression operand, Spanned <UnaryOperatorKind> operatorKind, TextSpan span) : base(span) { Operand = operand; OperatorKind = operatorKind; }
internal FunctionCallExpression( Spanned <string> targetName, ImmutableArray <Expression> arguments, TextSpan span) : base(span) { TargetName = targetName; Arguments = arguments; }
internal AssignmentExpression( Expression target, Spanned <AssignmentOperatorKind> operatorKind, Expression value, TextSpan span) : base(span) { Target = target; OperatorKind = operatorKind; Value = value; }
internal BinaryExpression( Expression left, Spanned <BinaryOperatorKind> operatorKind, Expression right, TextSpan span) : base(span) { Left = left; OperatorKind = operatorKind; Right = right; }
public SceneSymbol?LookupScene(Spanned <string> identifier) { SceneSymbol?scene = _module.LookupScene(identifier.Value); if (scene is not null) { return(scene); } ReportUnresolvedIdentifier(identifier); return(null); }
public ChapterSymbol?LookupChapter(Spanned <string> identifier) { ChapterSymbol?chapter = _module.LookupChapter(identifier.Value); if (chapter is not null) { return(chapter); } ReportUnresolvedIdentifier(identifier); return(null); }
public PrefixOperation(int nodeId, Token @operator, IExpression operand) { NodeId = nodeId; Span = SourceSpan.Merge(@operator.Span, operand.Span); Operator = new Spanned <PrefixOperator>( @operator.Kind switch { TokenKind.Bang => PrefixOperator.Not, TokenKind.Plus => PrefixOperator.Identity, TokenKind.Minus => PrefixOperator.Negate, TokenKind.Tilde => PrefixOperator.BinaryNot, _ => throw new ArgumentException(nameof(@operator)), },
private void ErrNoSuchFunction(Spanned<string> spName, TyRef[] args) { var builder = new StringBuilder().Append('|'); for (int i = 0; i < args.Length; i++) { if (i > 0) builder.Append(", "); builder.Append(args[i]); } builder.Append('|'); log.Error(spName.span, "No method \"{0}\" with parameter types {1} exists.", spName.value, builder.ToString()); }
public LookupResult LookupFunction(Spanned <string> identifier) { string name = identifier.Value; BuiltInFunction?builtInFunction = WellKnownSymbols.LookupBuiltInFunction(name); if (builtInFunction.HasValue) { return(new LookupResult(builtInFunction.Value)); } FunctionSymbol?function = _module.LookupFunction(name); if (function is not null) { return(new LookupResult(function)); } ReportUnresolvedIdentifier(identifier); return(LookupResult.Empty); }
public NodeInvoke(Spanned<string> spName, List<NodeExpr> args) { this.spName = spName; this.args = args; }
public NodeLet(Spanned<string> spName, Spanned<TyRef> spTy, NodeExpr value) { this.spName = spName; this.spTy = spTy; this.value = value; }
public static void AssertSpannedText(string text, string substring, Spanned <string> spannedSubstring) { Assert.Equal(substring, spannedSubstring.Value); Assert.Equal(SpanOf(text, substring), spannedSubstring.Span); }