示例#1
0
        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);
            }
        }
示例#2
0
 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);
         }
     }
 }
示例#3
0
        // 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;
        }
示例#4
0
 internal UnaryExpression(
     Expression operand,
     Spanned <UnaryOperatorKind> operatorKind,
     TextSpan span) : base(span)
 {
     Operand      = operand;
     OperatorKind = operatorKind;
 }
示例#5
0
 internal FunctionCallExpression(
     Spanned <string> targetName,
     ImmutableArray <Expression> arguments,
     TextSpan span) : base(span)
 {
     TargetName = targetName;
     Arguments  = arguments;
 }
示例#6
0
 internal AssignmentExpression(
     Expression target,
     Spanned <AssignmentOperatorKind> operatorKind,
     Expression value,
     TextSpan span) : base(span)
 {
     Target       = target;
     OperatorKind = operatorKind;
     Value        = value;
 }
示例#7
0
 internal BinaryExpression(
     Expression left,
     Spanned <BinaryOperatorKind> operatorKind,
     Expression right,
     TextSpan span) : base(span)
 {
     Left         = left;
     OperatorKind = operatorKind;
     Right        = right;
 }
示例#8
0
        public SceneSymbol?LookupScene(Spanned <string> identifier)
        {
            SceneSymbol?scene = _module.LookupScene(identifier.Value);

            if (scene is not null)
            {
                return(scene);
            }

            ReportUnresolvedIdentifier(identifier);
            return(null);
        }
示例#9
0
        public ChapterSymbol?LookupChapter(Spanned <string> identifier)
        {
            ChapterSymbol?chapter = _module.LookupChapter(identifier.Value);

            if (chapter is not null)
            {
                return(chapter);
            }

            ReportUnresolvedIdentifier(identifier);
            return(null);
        }
示例#10
0
 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)),
     },
示例#11
0
        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());
        }
示例#12
0
        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);
        }
示例#13
0
 public NodeInvoke(Spanned<string> spName, List<NodeExpr> args)
 {
     this.spName = spName;
     this.args = args;
 }
示例#14
0
 public NodeLet(Spanned<string> spName, Spanned<TyRef> spTy, NodeExpr value)
 {
     this.spName = spName;
     this.spTy = spTy;
     this.value = value;
 }
示例#15
0
 public static void AssertSpannedText(string text, string substring, Spanned <string> spannedSubstring)
 {
     Assert.Equal(substring, spannedSubstring.Value);
     Assert.Equal(SpanOf(text, substring), spannedSubstring.Span);
 }