예제 #1
0
        Data ReadCompound(CompoundSchema compound, ReadingContext parentContext)
        {
            if (ReadExtraCompoundFunc != null &&
                ReadExtraCompoundFunc(compound, parentContext, out var data))
            {
                return(data);
            }

            var state        = Document.ParameterLookup.BuildCompoundState(compound, parentContext.Argument);
            var interpreter  = new Interpreter(state);
            var compoundData = new Dictionary <string, Data>();

            foreach (var fieldSchema in compound.Fields)
            {
                var fieldData = ReadField(fieldSchema, interpreter, parentContext);
                if (fieldData == null)
                {
                    continue;
                }
                //state.Set(fieldSchema, Oldvalue.From(fieldData));
                compoundData[fieldSchema.Name] = fieldData;
            }

            return(new CompoundData()
            {
                Fields = compoundData,
                Schema = compound,
            });
        }
예제 #2
0
        TypeBuilder BuildCompoundType(ModuleBuilder moduleBuilder, CompoundSchema schema)
        {
            var name            = schema.Name.ToPascalCase();
            var attr            = TypeAttributes.Public;
            var compoundBuilder = moduleBuilder.DefineType(name, attr);

            return(compoundBuilder);
        }
예제 #3
0
        GenericTypeParameterBuilder BuildTemplateType(TypeBuilder compoundBuilder, CompoundSchema schema)
        {
            if (!schema.Generic)
            {
                return(null);
            }

            string[] typeParamNames = { "T" };
            var      typeParams     = compoundBuilder.DefineGenericParameters(typeParamNames);

            return(typeParams[0]);
        }
예제 #4
0
        public Instruction ConstructCompound(CompoundSchema schema)
        {
            var baseType     = DocBuilder.SchemaTypes.SchemaTypesByName[schema.Name];
            var templateType = DocBuilder.SchemaTypes.TemplateTypeByName[schema.Name];

            var fields       = DocBuilder.SchemaFields.GetBuildersForType(schema.Name);
            var state        = new ExpressionWriter.State(fields, new string[] { "Argument" });
            var instructions = fields
                               .Select(sb => ConstructField(sb.Item1, sb.Item2, state))
                               .ToArray();

            return(new Instruction.Set(
                       new Instruction.Set(instructions),
                       new Instruction.Return()
                       ));
        }
예제 #5
0
        public Instruction ReadCompoundValue(FieldSchema field, CompoundSchema compound)
        {
            var fieldType   = DocBuilder.SchemaFields.FieldTypes[field];
            var constructor = DocBuilder.SchemaConstructors.CompoundConstructors[compound] as ConstructorInfo;

            if (field.Template != null)
            {
                constructor = TypeBuilder.GetConstructor(fieldType, constructor);
            }

            if (constructor == null)
            {
                throw new Exception();
            }

            return(new Instruction.Set(
                       new Instruction.LoadArgument(1),
                       new Instruction.LoadInt64(0),
                       new Instruction.NewObject(constructor)
                       ));
        }
예제 #6
0
 public Interpreter.State BuildCompoundState(CompoundSchema compound, long argument)
 {
     return(null);
 }