コード例 #1
0
ファイル: SizeofNode.cs プロジェクト: Blecki/DCPUB
        public override void ResolveTypes(CompileContext context, Model.Scope enclosingScope)
        {
            _struct = enclosingScope.FindType(typeName);
            if (_struct == null)
            {
                CachedFetchToken = Constant(0);
                context.ReportError(this, "Could not find type " + typeName);
            }
            else if (_struct.size == 0)
            {
                throw new InternalError("Struct size must be determined before types are resolved.");
            }
            else
                CachedFetchToken = Constant((ushort)_struct.size);

             ResultType = "word";
        }
コード例 #2
0
ファイル: OffsetOfNode.cs プロジェクト: Blecki/DCPUB
        public override void ResolveTypes(CompileContext context, Model.Scope enclosingScope)
        {
            _struct = enclosingScope.FindType(typeName);

            if (_struct == null)
            {
                context.ReportError(this, "Could not find type " + typeName);
                CachedFetchToken = Constant(0);
            }
            else
            {
                var memberIndex = _struct.members.FindIndex(m => m.name == memberName);
                if (memberIndex < 0)
                {
                    context.ReportError(this, "Member not found : " + memberName);
                    CachedFetchToken = Constant(0);
                }
                else
                    CachedFetchToken = Constant((ushort)memberIndex);
            }

            ResultType = "word";
        }