示例#1
0
    void Header(YSParseNode HeaderNode)
    {
        List <string> Resource_Sources = new List <string> ();
        YSLinker      Linker           = new YSLinker();

        foreach (YSParseNode HeaderItem in HeaderNode.Children)
        {
            if (HeaderItem.Type == NType.Import)
            {
                Resource_Sources.Add(HeaderItem.Children [0].Token.Content);
            }
            else
            {
                Error("Unrecognized header type");
            }
        }
        foreach (YSLinker.Resource Resource in Linker.LoadResources(Resource_Sources.ToArray()))
        {
            ScopeFrame ResourceScope = new ScopeFrame(Resource.Name, ScopeFrame.FrameTypes.Structure);
            STATE.PushScope(ResourceScope);
            Yumascript.LPIProcess(ref STATE, Resource.Content);
            StructureFrame SFrame = STATE.PopScopeNoSave();

            IDPacket ResourceFrameID = IDPacket.CreateIDPacket(STATE, Resource.Name, IdentityType.Structure);
            STATE.PutGeneric(ResourceFrameID, SFrame);
        }
    }
示例#2
0
    void Loop(YSParseNode LoopNode)
    {
        Current = LoopNode;
        YSParseNode ConditionNode = LoopNode.Children [1];
        ScopeFrame  LoopFrame     = new ScopeFrame(STATE.current_scope, "Loop@" + LoopNode.Children [0].Token.Position, ScopeFrame.FrameTypes.Loop);

        STATE.PushScope(LoopFrame);

        IDPacket EVAL_COND = Expression(ConditionNode);

        ExpectType(IdentityType.Boolean, EVAL_COND.Type);
        bool EVAL_VAL;

        STATE.TryGetBoolean(EVAL_COND, out EVAL_VAL);
        while (EVAL_VAL)
        {
            Block(LoopNode.Children [2]);
            EVAL_COND = Expression(ConditionNode);
            STATE.TryGetBoolean(EVAL_COND, out EVAL_VAL);
        }

        STATE.PopScope();
    }
示例#3
0
    void Loop(YSParseNode LoopNode)
    {
        Current = LoopNode;
        YSParseNode ConditionNode = LoopNode.Children [1];
        ScopeFrame LoopFrame = new ScopeFrame (STATE.current_scope, "Loop@" + LoopNode.Children [0].Token.Position, ScopeFrame.FrameTypes.Loop);
        STATE.PushScope (LoopFrame);

        IDPacket EVAL_COND = Expression (ConditionNode);
        ExpectType (IdentityType.Boolean, EVAL_COND.Type);
        bool EVAL_VAL;
        STATE.TryGetBoolean (EVAL_COND, out EVAL_VAL);
        while (EVAL_VAL) {
            Block (LoopNode.Children [2]);
            EVAL_COND = Expression (ConditionNode);
            STATE.TryGetBoolean (EVAL_COND, out EVAL_VAL);
        }

        STATE.PopScope ();
    }
示例#4
0
    IDPacket IdentityStructure(YSParseNode IStructureNode)
    {
        Debug ("Resolving structure identity");
        Current = IStructureNode;
        string StructureName = IStructureNode.Children [0].Token.Content;
        StructureFrame Frame;
        GenericFrame GFrame;
        Debug ("Attempting to find structure " + StructureName + " in " + STATE.current_scope.Name);
        IDPacket SID = IDPacket.CreateIDPacket (STATE, StructureName, IdentityType.Structure);
        STATE.TryGetGeneric (SID, out GFrame);
        Frame = (StructureFrame)GFrame;

        ScopeFrame SF = new ScopeFrame (STATE.current_scope, StructureName, ScopeFrame.FrameTypes.Structure);
        SF.MergeForScope (StructureName, Frame);
        STATE.PushScope (SF);

        IDPacket ReturnPacket = null;
        if (IStructureNode.Children.Count > 1) {
            //child Identity
            YSParseNode INode = IStructureNode.Children [1];
            if (INode.Type != NType.Identity
                && INode.Type != NType.IdentityStructure
                && INode.Type != NType.IdentityFunction)
                Error ("Structure child is not an Identity");
            Debug ("Attempting to find identity " + INode.Children [0].Token.Content + " in " + STATE.current_scope.Name);
            ReturnPacket = Identity (INode);
        } else {
            Error ("Structure chain has no children");
        }

        STATE.PopScopeNoSave ();

        if (ReturnPacket == null)
            Error ("Attempting to resolve a structure chain that ends improperly");

        return ReturnPacket;
    }
示例#5
0
    void Header(YSParseNode HeaderNode)
    {
        List<string> Resource_Sources = new List<string> ();
        YSLinker Linker = new YSLinker ();
        foreach (YSParseNode HeaderItem in HeaderNode.Children) {
            if (HeaderItem.Type == NType.Import) {
                Resource_Sources.Add (HeaderItem.Children [0].Token.Content);
            } else {
                Error ("Unrecognized header type");
            }
        }
        foreach(YSLinker.Resource Resource in Linker.LoadResources (Resource_Sources.ToArray ())) {
            ScopeFrame ResourceScope = new ScopeFrame (Resource.Name, ScopeFrame.FrameTypes.Structure);
            STATE.PushScope (ResourceScope);
            Yumascript.LPIProcess (ref STATE, Resource.Content);
            StructureFrame SFrame = STATE.PopScopeNoSave ();

            IDPacket ResourceFrameID = IDPacket.CreateIDPacket (STATE, Resource.Name, IdentityType.Structure);
            STATE.PutGeneric (ResourceFrameID, SFrame);
        }
    }
示例#6
0
    IDPacket ExpressionList(YSParseNode ExpressionListNode, ref List<int> DimensionsReversed, ref IdentityType ResolvedType)
    {
        DIMCNT = 0;
        Debug ("Expression List Resolving");
        //STATE.PutStructure (ARRAY, ArrayFrame);

        if (ExpressionListNode.Children.Count < 1) {
            Debug ("Expression List had no children");
            return null;
        }

        IDPacket ARRAY = IDPacket.CreateSystemPacket ("EXPL_TEMP", IdentityType.Structure);
        ScopeFrame ArrayScope = new ScopeFrame (new StructureFrame(), ARRAY.Name, ScopeFrame.FrameTypes.None);
        STATE.PushScope (ArrayScope);

        //List<IDPacket> RESULT = new List<IDPacket> ();
        //Look at the first node, all other nodes must conform to this node's type
        int NC = 0;
        YSParseNode FirstNode = ExpressionListNode.Children [NC++];
        //IdentityType ListType;
        int ListDimensions = 0;
        if (FirstNode.Type == NType.ExpressionList) {
            ListDimensions++;
            IDPacket IEXPL = ExpressionList (FirstNode, ref DimensionsReversed, ref ResolvedType);
            DimensionsReversed.AddRange (new List<int>(DimensionsReversed));
            //RESULT.Add (IEXPL);
            IDPacket FIRST = IDPacket.CreateIDPacket (STATE, "0", IdentityType.Structure);
            STATE.COPY (FIRST, IEXPL);
        } else {
            IDPacket EXP = Expression (FirstNode);
            ResolvedType = EXP.Type;
            if (!STATE.IsPrimitive (ResolvedType))
                Error ("Expression Lists can only contain identities that resolve to Primitive Types");
            //RESULT.Add (EXP);
            IDPacket FIRST = IDPacket.CreateIDPacket (STATE, "0", EXP.Type);
            STATE.COPY (FIRST, EXP);
        }
        int ELEMENT_COUNT = 1;
        while (NC < ExpressionListNode.Children.Count) {
            YSParseNode Node = ExpressionListNode.Children [NC++];
            if (Node.Type != FirstNode.Type)
                Error (String.Format("All children in an expression list must have the same dimensions " +
                    "Expecting {0} got {1}",
                    FirstNode.Type, Node.Type));
            if (FirstNode.Type == NType.ExpressionList) {
                IdentityType NodeType = IdentityType.Unknown;
                int NodeDimensions = 0;
                IDPacket NEXPL = ExpressionList (Node, ref DimensionsReversed, ref NodeType);
                if (NodeDimensions != ListDimensions) {
                    Error (String.Format ("All children of an expression list must have matching dimensions. " +
                    "Expected dimensions:{0} Found:{1}",
                        ListDimensions, NodeDimensions));
                }
                if (NodeType != ResolvedType) {
                    Error (String.Format ("All children of an expression list must have matching types. " +
                    "Expected type:{0} Found:{1}",
                        ResolvedType, NodeType));
                }
                //RESULT.Add (NEXPL);
                IDPacket NODE = IDPacket.CreateIDPacket (STATE, "" + ELEMENT_COUNT++, IdentityType.Structure);
                STATE.COPY (NODE, NEXPL);
            } else {
                IDPacket NEXP = Expression (Node);
                if (NEXP.Type != ResolvedType) {
                    Error (String.Format ("All children of an expression list must have matching types. " +
                    "Expected type:{0} Found:{1}",
                        ResolvedType, NEXP.Type));
                }
                //RESULT.Add (NEXP);
                IDPacket NODE = IDPacket.CreateIDPacket (STATE, "" + ELEMENT_COUNT++, NEXP.Type);
                STATE.COPY (NODE, NEXP);
            }
        }
        DIMCNT = ELEMENT_COUNT;
        DimensionsReversed.Add (DIMCNT);

        ArrayScope = STATE.PopScopeNoSave ();

        ArrayFrame ArrayFrame = new ArrayFrame (new IdentityType[] { ResolvedType });
        ArrayFrame.Merge ((GenericFrame)ArrayScope);
        ArrayFrame.ResolvedType = ResolvedType;
        DimensionsReversed.Reverse ();
        ArrayFrame.Dimensions = DimensionsReversed.ToArray();
        ARRAY.ArrayType = ResolvedType;
        STATE.PutGeneric (ARRAY, ArrayFrame);

        //ResolvedType = RESOLVED_TYPE;
        return ARRAY;
    }